wallet_prepareCalls
Prepares a call bundle.
It returns a digest
of the call bundle to sign over, as well as the parameters required to fulfil a wallet_sendPreparedCalls
request (context
).
Request
type Request = {
method: 'wallet_prepareCalls',
params: [{
/** Calls to prepare. */
calls: {
/** Recipient. */
to: `0x${string}`;
/** Calldata. */
data?: `0x${string}`;
/** Value to transfer. */
value?: `0x${string}`;
}[];
/** Capabilities to use for this request. */
capabilities?: {
/** Custom fee token to use. */
feeToken?: `0x${string}`;
/** Permissions to use for this request. */
permissions?: {
/** ID of the permission. */
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}`;
/**
* Key that will be used to sign over the digest.
*/
key: {
/** Whether the key prehashes digests before signing (e.g. WebCrypto P256). */
prehash?: boolean;
/** Public key. Accepts an address for `address` & `secp256k1` types. */
publicKey: `0x${string}`,
/** Key type. */
type: 'address' | 'secp256k1' | 'p256' | 'webauthn-256'
};
/**
* 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 = {
/** Chain ID the calls were prepared for. */
chainId: `0x${string}`;
/**
* Data to be forwarded to `wallet_sendPreparedCalls`.
*/
context: unknown;
/** Digest to sign over. */
digest: `0x${string}`;
/**
* Key that will be used to sign over the digest.
*/
key: {
publicKey: `0x${string}`;
type: 'address' | 'secp256k1' | 'p256' | 'webauthn-256';
};
}
Example
import { Porto } from 'porto'
const { provider } = Porto.create()
const response = await provider.request({
method: 'wallet_prepareCalls',
params: [{
calls: [{
to: '0xcafebabecafebabecafebabecafebabecafebabe',
value: '0x12345678',
}],
key: {
publicKey: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
type: 'p256'
},
}]
})