Transactions

Sponsor gas

Sponsor gas fees for transactions using EIP-7702 or ERC-4337. Thirdweb will handle the gas fees for you.

Sponsor gas fees using EIP-7702, enabling gasless transactions and improving user experience.

EIP-7702 is the default execution mode in the thirdweb API for your user and server wallets.

Example sponsored contract write request:

Request

fetch("https://api.thirdweb.com/v1/contracts/write", {
method: "POST",
headers: {
"x-secret-key": "<your-project-secret-key>",
},
body: {
calls: [
{
contractAddress: "0xe352Cf5f74e3ACfd2d59EcCee6373d2Aa996086e",
method: "function approve(address spender, uint256 amount)",
params: [
"0x4fA9230f4E8978462cE7Bf8e6b5a2588da5F4264",
1000000000,
],
},
],
chainId: 84532,
from: "0x1234567890123456789012345678901234567890",
},
});

Response

{
"result": {
"transactionIds": [
"string"
]
}
}

That's it! All transactions executed by the user will be sponsored via the thirdweb infrastructure.