mega.callContract()
Execute any contract write function through the wallet. Supports single calls or a batch array. With silent: true and a matching Smart Approvals grant, calls skip the approval UI and execute directly.
Signature
mega.callContract(request: CallContractRequest | CallContractRequest[]): Promise<TransactionResult>
Parameters
CallContractRequest:
address
`0x${string}`
required
Contract address.
abi
any
optional
Contract ABI fragment. Required unless data is pre-encoded.
functionName
string
optional
Function to call. Required unless data is pre-encoded.
args
any[]
optional
Function arguments.
data
`0x${string}`
optional
Pre-encoded calldata (alternative to abi/functionName/args).
silent
boolean
optional
Skip approval UI. Requires a matching session grant on { to, signature }.
silentUIApproveFallback
boolean
optional
When silent: true but the matching permission has expired, fall back to UI approval instead of failing silently.
value
bigint / string
optional
Native value to send (wei).
sponsor
boolean
optional
Request sponsorship in explicit mode.
maxGasAllowance
bigint
optional
Override the default max gas allowance — use when sending large payloads that exceed defaults.
For batch calls, pass an array. The wallet shows one approval for the whole batch.
Examples
Single call:
Silent execution after a permission grant:
Batch:
Response
Shared TransactionResult shape. For batch calls, result.receipts is populated instead of result.receipt.
Notes
silent: trueonly works after a successfulgrantPermissions()covering the exact{ to, signature }pair. If the grant is missing or expired, the call resolves withstatus: 'error'.For read calls (no transaction), use
getFromContract().Types are intentionally broad — create typed wrappers in your app for contracts you call repeatedly.
Last updated