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}`;
}[];
/**
* 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}`;
/** Capabilities. */
capabilities?: {
permissions?: {
/** ID of the permission to use. */
id: `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: '0x706aa5c8e5cc2c67da21ee220718f6f6b154e75c',
data: encodeFunctionData({
abi: parseAbi([
'function mint(address, uint256)',
]),
functionName: 'mint',
args: [account, parseEther('100')],
}),
}],
}],
})