Blockchain's most advanced smart wallet
FunWallet is the core component of the FunWallet SDK. It represents a smart contract wallet deployed (or yet to be deployed) on a Blockchain.
FunWallets are responsible for:
Asset Custody User Verification Data Orchestration
const wallet = new FunWallet ( )
transfer
Transfer tokens or base currencies
const receipt = await wallet . transfer ( auth , input , options )
auth
Ethers.Wallet object
Required
EOA used to authenticate a FunWallet Transaction
Object containing information such as token/coin type, amount & receiver address
When used, the transaction becomes an ERC-20 transfer, while its absence defaults to an native token transfer
Amount of tokens denoted in token decimal
wallet.transfer(auth,{to:address, token:"usdc", amount:1})
wallet =transfer=> address 1 * 10^6 usdc tokens
Address receiving the transfer
Default environment configuration variables to be overridden
- If options.sentTxLater is false :
Receipt of a Transaction execution/deployment
- If options.sentTxLater is true :
transaction
Transaction object
Signed Transaction object ready to be executed/deployed
swap
Swaps to & from tokens/coins
const receipt = await wallet . swap ( auth , input , options )
auth
Ethers.Wallet object
Required
EOA used to authenticate a FunWallet Transaction
Object containing information such as from token, to token, amount, slippage, receiver address pool fee
in
address || string
Required
out
address || string
Required
Amount of in token to send to swap
Percent slippage allowed.
Default environment configuration variables to be overridden
- If options.sentTxLater is false :
Receipt of a Transaction execution/deployment
- If options.sentTxLater is true :
transaction
Transaction object
Signed Transaction object ready to be executed/deployed
approve
Approve a 3rd party to spend a FunWallet's tokens
const receipt = await wallet . approve ( auth , input , options )
auth
Ethers.Wallet object
Required
EOA used to authenticate a FunWallet Transaction
Object containing information such as spender, amount & token
token
address || string
Required
Amount of tokens denoted in token decimal
wallet.approve(auth,{to:address, token:"usdc", amount:1})
wallet =approve=> address 1 * 10^6 usdc tokens
Address receiving the approval
Default environment configuration variables to be overridden
- If options.sentTxLater is false :
Receipt of a Transaction execution/deployment
- If options.sentTxLater is true :
transaction
Transaction object
Signed Transaction object ready to be executed/deployed
getAddress
Returns a FunWallet's address
const address = await wallet . getAddress ( options )
Default environment configuration variables to be overridden
execute
Executes an Action
const receipt = await wallet . execute ( auth , actionFunc , options )
auth
Ethers.Wallet object
Required
EOA used to authenticate a FunWallet Transaction
actionFunc
function
Required
Function returning Transaction calldata
Default environment configuration variables to be overridden
- If options.sentTxLater is false :
Receipt of a Transaction execution/deployment
- If options.sentTxLater is true :
transaction
Transaction object
Signed Transaction object ready to be executed/deployed
sendTx
Sends a Transaction to a blockchain
const receipt = await wallet . sendTx ( { auth , tx } , options )
auth
Ethers.Wallet object
Required
EOA used to authenticate a FunWallet Transaction
tx
Transaction object
Required
Transaction to be sent to a blockchain
Default environment configuration variables to be overridden
Receipt of a Transaction execution/deployment
sendTxs
Sends multiple Transactions to a blockchain
const receipt = await wallet . sendTxs ( { auth , txs } , options )
auth
Ethers.Wallet object
Required
EOA used to authenticate FunWallet Transactions
tx
List of Transaction objects
Required
Transactions to be sent to a blockchain
Default environment configuration variables to be overridden
Receipts of Transaction executions/deployments
execRawTx
A method that allows FunWallets to execute Transactions with arbitrary
calldata
const contract = new ethers . Contract ( contractAddress , contractAbi )
const input = await contract . populateTransaction . functionName ( functionParameters )
const receipt = await wallet . execRawTx ( auth , input , options )
auth
Object of type Auth
Required
Authenticator of the Transaction
Object representing an unsigned Transaction, with elements from, to & data, all values obtained by creating a regular EVM transaction
Default environment configuration variables to be overridden
Receipts of Transaction executions/deployments
getAddress
Static method that gets the address of a FunWallet
const address = await FunWallet . getAddress ( authId , index , chain , apiKey )
String representing a FunWallet authenticator's Id. A public key if an EOA and something like 'twitter###my-twitter-username' for social authenticator
Index of the FunWallet created with the same authId
Chain on which the FunWallet is located
A developer's Fun API key
Receipts of Transaction executions/deployments
getAddressOffline
Static method that gets the address of a FunWallet with a single social owner & without needing Fun to be online
const address = await FunWallet . getAddress ( authId , index , rpcUrl , factoryAddress )
String representing a FunWallet authenticator's Id. Something like 'twitter###my-twitter-username'
Index of the FunWallet created with the same authId
factoryAddress
object
Required
The address of the factory smart contract used to create the FunWallet
Receipts of Transaction executions/deployments