When creating an account, you can specify the signers that will be used to authorize the transactions.
The SDK will install and set up the corresponding validator modules to authorize the signers of your choice. The account will use the same configuration across all chains.
Signers
At its core, Rhinestone accounts support two validation modules: ECDSA (for EOAs) and WebAuthn (for passkeys). You can then mix and match those validators to tailor them to your use case.
- EOAs: you can use embedded wallets (Privy, Dynamic), external wallets (MetaMask, Coinbase), and server-side (agent) wallets. See below for an example of using an external wallet as the account owner.
- Passkey: use device biometrics to authorize transactions. Learn more about using passkeys.
- Multisig: use multiple signers of the same type to validate transactions. Learn more about using multisigs.
- MFA: use passkeys and EOAs at the same time. Learn more about using MFAs.
Example
Here, we create an account owned by an external wallet like MetaMask and send our first transaction.
Install dependencies
Install viem and @rhinestone/sdk:npm install viem @rhinestone/sdk
Initialize Viem
Initialize Viem client for the browser wallet:const chain = sepolia;
const accountClient = createWalletClient({
chain,
transport: custom(window.ethereum!),
account: eoaAddress,
});
Initialize Rhinestone account
Create an account using the external wallet as the sole owner:const rhinestone = new RhinestoneSDK()
const account = walletClientToAccount(accountClient);
console.log(account);
const rhinestoneAccount = await rhinestone.createAccount({
owners: {
type: "ecdsa",
accounts: [account],
},
});
console.log(rhinestoneAccount);
const accountAddress = rhinestoneAccount.getAddress();
console.log(accountAddress);
Make a transaction
Make your first transaction with the smart account:const transactionResult = await rhinestoneAccount.sendTransaction({
chain,
calls: [
{
to: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
data: "0x",
},
],
});
console.log(transactionResult);
This will prompt a signature request from the browser wallet and create and submit the transaction from the smart account.
Custom Nonce
By default, the SDK uses a nonce of 0 to derive the account address. You can provide a custom nonce to derive a different address for the same set of owners. This is useful when you need multiple accounts per signer.
const rhinestoneAccount = await rhinestone.createAccount({
owners: { type: 'ecdsa', accounts: [account] },
account: {
type: 'safe',
nonce: 1n,
},
})
Using a different nonce will result in a different account address, even if the owners are the same.