MagicSpend is a contract that allows onchain accounts to present valid Withdraw Requests and receive funds. A Withdraw Request is defined as
struct WithdrawRequest {
bytes signature;
address asset;
uint256 amount;
uint256 nonce;
uint48 expiry;
}
Where signature is an EIP-191 compliant signature of the message
abi.encode(
<MagicSpend contract address>,
<UserOperation.sender and/or msg.sender of the withdraw call>,
<chain ID>,
withdrawRequest.asset,
withdrawRequest.amount,
withdrawRequest.nonce,
withdrawRequest.expiry
)
MagicSpend is an ERC-4337 compliant paymaster (EntryPoint v0.6) and also enables withdraw requests with asset ETH (address(0)) to be used to pay transaction gas.
This contract is part of a broader MagicSpend product from Coinbase, which as a whole allows Coinbase users to seamlessly use their assets onchain.
We have started a discussion around a possible new wallet RPC to enable apps to have better awareness of this "just in time" funding.
When the withdrawing account is an ERC-4337 compliant smart contract (like Smart Wallet), there are three different ways the MagicSpend smart contract can be used
UserOperation.sender, a smart contract wallet (SCW), to validate the user operation.UserOperation.calldataUserOperation.calldata.This is the simplest flow. The MagicSpend account is agnostic to any details of this transaction, even whether or not the caller is a SCW. It simply validates the withdraw and transfers funds if valid.
This flow is like "Pay gas only” with the addition of (7.) and (8.). Here, the SCW also requests funds during execution. In this flow, a user might be, for example, trying to mint an NFT and needs funds for the mint.
| Network | Contract Address |
|---|---|
| Base | 0x011A61C07DbF256A68256B1cB51A5e246730aB92 |
| Base Sepolia | 0x011A61C07DbF256A68256B1cB51A5e246730aB92 |
After cloning the repo, run the tests using Forge, from Foundry
forge test
You can run the echinda tests with this make command
make echidna-test
Solidity
99.7%
MagicSpend is a contract that allows onchain accounts to present valid Withdraw Requests and receive funds. A Withdraw Request is defined as
struct WithdrawRequest {
bytes signature;
address asset;
uint256 amount;
uint256 nonce;
uint48 expiry;
}
Where signature is an EIP-191 compliant signature of the message
abi.encode(
<MagicSpend contract address>,
<UserOperation.sender and/or msg.sender of the withdraw call>,
<chain ID>,
withdrawRequest.asset,
withdrawRequest.amount,
withdrawRequest.nonce,
withdrawRequest.expiry
)
MagicSpend is an ERC-4337 compliant paymaster (EntryPoint v0.6) and also enables withdraw requests with asset ETH (address(0)) to be used to pay transaction gas.
This contract is part of a broader MagicSpend product from Coinbase, which as a whole allows Coinbase users to seamlessly use their assets onchain.
We have started a discussion around a possible new wallet RPC to enable apps to have better awareness of this "just in time" funding.
When the withdrawing account is an ERC-4337 compliant smart contract (like Smart Wallet), there are three different ways the MagicSpend smart contract can be used
UserOperation.sender, a smart contract wallet (SCW), to validate the user operation.UserOperation.calldataUserOperation.calldata.This is the simplest flow. The MagicSpend account is agnostic to any details of this transaction, even whether or not the caller is a SCW. It simply validates the withdraw and transfers funds if valid.
This flow is like "Pay gas only” with the addition of (7.) and (8.). Here, the SCW also requests funds during execution. In this flow, a user might be, for example, trying to mint an NFT and needs funds for the mint.
| Network | Contract Address |
|---|---|
| Base | 0x011A61C07DbF256A68256B1cB51A5e246730aB92 |
| Base Sepolia | 0x011A61C07DbF256A68256B1cB51A5e246730aB92 |
After cloning the repo, run the tests using Forge, from Foundry
forge test
You can run the echinda tests with this make command
make echidna-test
Solidity
99.7%