what is smart account and safe
overview
Safe provide a sdk to create a smart contract account which is a fully customizable acocunt.
In crypto if you give away your private key,your money is gone.You can’t take them back.Smarct account is built to prevent those.
Common usecase:
- multiple-signer(2 or more)
- set spending limit(e.g. $100 perday)
Smart Account vs Signing Accounts(EOA)
Difference between two type of accounts
safe {core}
safe {core} consist of 3 parts.
safe {core} AA SDK
Interact with your application directly.
safe {core} API
Provide safe account related information.
safe {core} protocol
Smart contract account standard and programmable.
Safe AA SDK
protocol kit
1.Install Dependencies
1 | yarn add ethers@5.7.2 @safe-global/safe-core-sdk \ |
2.Create .env config file
1 | touch .env |
3.Init
1 | import { ethers } from 'ethers' |
4.Deploy your safe
1 | import { SafeAccountConfig } from "@safe-global/safe-core-sdk"; |
auth Kit
The Auth kit creates an Ethereum address and authenticates a blockchain account using an email address, social media account, or traditional crypto wallets like Metamask.
1 | await safeAuthKit.signIn(); |
relay kit
The Relay Kit allows users to pay transaction fees (gas fees) using the native blockchain token or ERC-20 tokens. This allows you to pay gas fees using any ERC-20 token in your Safe, even if you don’t have ETH.
1 | yarn add @safe-global/relay-kit |
1 | import { GelatoRelayAdapter } from "@safe-global/relay-kit"; |
1 | import { |
onramp kit
This package is provided for testing purposes only
Safe API
Network | Host |
---|---|
Ethereum Mainnet | https://safe-transaction-mainnet.safe.global |
Goerli | https://safe-transaction-goerli.safe.global |
Safe Protocol
Modules
Modules are smart contracts that add custom features to Safe contracts. They separate module logic from the Safe’s core contract, and are added or removed with confirmation from all owners. Modules are critical for security and emit events when added, removed, or when module transactions succeed or fail. There are many types of modules, including daily spending allowances, recurring transactions, standing orders, and social recovery modules, which can help you recover a Safe if you lose access to owner accounts. Modules can be used in various ways to enhance your Safe’s functionality.
Guards
Transaction guards can make checks before and after a Safe transaction.