Get Wallet Address

Get the address of a FunWallet.


The address of a FunWallet is computed deterministically from the the auth ID & the index. Learn more about this deterministic address computation here.

There are 2 ways to get the address of a FunWallet:

  • Online: Using a chain & API key.

  • Offline: Using an RPC URL & a factory address.




Get FunWallet Address Online

The following code flow computes the address of a FunWallet with a single signer: A Twitter account. This flow requires Fun's systems to be operational.

Note, the following code requires an auth id for the relevant FunWallet. If the FunWallet has a single EOA owner, then this parameter is the public key of the EOA. If the FunWallet has mulitple owners (EOAs or social accounts), then this parameter is either one of the auth ids for each of the owners. If it's a social account, the auth id is a string in the form "twitter###elonmusk".

,
get-address.js
const { FunWallet } = require("fun-wallet")
const getAddr = async () => {
// Any of the auth IDs for the relevant FunWallet are valid parameters here
const TWITTER_HANDLE = "elonmusk"
const AUTH_ID = "twitter###" + TWITTER_HANDLE
const CHAIN = "ethereum-goerli"
const API_KEY = "MYny3w7xJh6PRlRgkJ9604sHouY2MTke6lCPpSHq"
const addr = await FunWallet.getAddress(AUTH_ID, 0, CHAIN, API_KEY)
console.log(addr)
}
getAddr()

Get FunWallet Address Offline

The following code flow computes the address of a FunWallet with a single signer: A Twitter account. This flow does not require Fun's systems to be operational.

Note, the following code flow is accurate only if the FunWallet corresponding to the computed address has only 1 social signer as an owner. This method will not work with EOA signers or with multiple social signers.

Note, this only works on chains where there is a deployed factory contract. Currenlty only the Göerli testnet has a deployed factory contract. However, a developer may choose to deploy their own factory contracts on other chains.

,
get-address.js
const { FunWallet } = require("fun-wallet")
const getAddr = async () => {
const TWITTER_HANDLE = "elonmusk"
const AUTH_ID = "twitter###" + TWITTER_HANDLE
const RPC_URL = "https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
const FACTORY_ADDR = "0x4FDffD240962F560BD3CA859a60034baa51ce3b2"
const addr = await FunWallet.getAddress(AUTH_ID, 0, RPC_URL, FACTORY_ADDR)
console.log(addr)
}
getAddr()