wallet_sendCalls
Requests for the Wallet to broadcast a bundle of calls to the network.
Request
type Request = {
method: 'wallet_sendCalls',
params: [{
/** Calls to prepare. */
calls: {
/** Recipient. */
to: `0x${string}`;
/** Calldata. */
data?: `0x${string}`;
/** Value to transfer. */
value?: `0x${string}`;
}[];
/** Capabilities. */
capabilities?: {
/** Custom fee token to use. */
feeToken?: `0x${string}`;
/** Permissions to use for this request. */
permissions?: {
/** ID of the permission to use. */
id: `0x${string}`;
};
/** URL of the sponsor endpoint that will front the request. */
sponsorUrl?: string
};
/**
* Chain ID to send the calls to.
* If not provided, the current chain will be used.
*/
chainId?: `0x${string}`;
/**
* Address of the account to send the calls from.
* If not provided, the Account will be filled by the Wallet.
*/
from?: `0x${string}`;
}]
}
Response
type Response = {
/** ID of the bundle. */
id: string;
}
Example
import { Porto } from 'porto'
const { provider } = Porto.create()
const response = await provider.request({
method: 'wallet_sendCalls',
params: [{
calls: [{
to: '0xcafebabecafebabecafebabecafebabecafebabe',
value: '0x12345678',
}],
}]
})
Mint ERC20 Tokens
The example below demonstrates minting 100 EXP on the Odyssey testnet.
import { encodeFunctionData, parseAbi, parseEther } from 'viem'
const [account] = await provider.request({
method: 'eth_accounts',
})
const hash = await provider.request({
method: 'wallet_sendCalls',
params: [{
calls: [{
to: '0x29f45fc3ed1d0ffafb5e2af9cc6c3ab1555cd5a2',
data: encodeFunctionData({
abi: parseAbi([
'function mint(address, uint256)',
]),
functionName: 'mint',
args: [account, parseEther('100')],
}),
}],
}],
})