Sponsored Paymaster
Available on ZKsync Era mainnet, ZKsync Sepolia, Cronos zkEVM Mainnet, Cronos zkEVM Tesnet, Abstract Tesnet, Abstract Mainnet.
Step 1: Send the API request
// Define the payload
const payload = {
chainId: 324, // Optional, defaults to zkSync Era Mainnet; valid options are 324, 300 (ZkSync-Sepolia), 388 (Cronos zkEVM Mainnet), 282 (Cronos zkEVM Testnet) and 11124 (Abstract Testnet).
feeTokenAddress: // ERC20 the user desires to use as gas token
sponsorshipRatio: // [0-100] which % of the transaction is sponsored by the protocol
replayLimit: // Optional (default of 5), how many times the user can execute the transaction
txData: {
from: "0x...",
to: "0x...",
data: "0x.."
}
};
// Define the function to perform the POST request
async function postTransactionData() {
try {
const response = await fetch('https://api.zyfi.org/api/erc20_sponsored_paymaster/v1', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': '<API Key>'
},
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log(data); // Process the response data
} catch (error) {
console.error('Error during the API call:', error);
}
}
Step 2: Show the quote to the user
Step 3: Execute the transaction
Last updated