Overview
Smart Account requires the
@magic-ext/smart-account extension.- Gas sponsorship — sponsor transaction fees for your users via an Alchemy Gas Manager policy
- Batched calls — send multiple contract calls in a single atomic transaction
- Cross-chain support — use any EVM chain supported by Alchemy
Prerequisites
- An Alchemy account with an API key
- (Optional) A Gas Manager policy ID for gas sponsorship
Setup
Install the Smart Account extension:JavaScript
Configuration Options
| Parameter | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Your Alchemy API key |
paymasterPolicyId | string | No | Alchemy Gas Manager policy ID. When provided, transaction fees are sponsored |
Sending a Transaction
UsesmartAccount.sendTransaction() to send one or more calls through the smart account:
JavaScript
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | The chain ID for the transaction |
calls | array | Yes | Array of calls to execute |
calls array accepts:
| Field | Type | Required | Description |
|---|---|---|---|
to | string | Yes | The recipient or contract address |
data | string | No | Encoded calldata for contract interactions |
value | string | No | Value to send in wei |
Response
| Field | Type | Description |
|---|---|---|
id | string | The call bundle ID |
transactionHash | string | undefined | The on-chain transaction hash |
chainId | number | The chain ID the transaction was sent on |
Batched Transactions
Send multiple calls in a single atomic transaction. All calls execute together — if one fails, they all revert.JavaScript
Gas Sponsorship
When apaymasterPolicyId is provided in the extension config, transaction gas fees are automatically sponsored through Alchemy’s Gas Manager. Users don’t need any ETH to send transactions.
JavaScript
Complete Example
JavaScript