โฝHoldstation Gas Station
How to Integrate with Holdstation Gas Station?
//// PAYMASTER with EOA Wallet
import { Contract, Provider, types, utils, Wallet } from 'zksync-web3';
import { ethers } from 'ethers';
const PAYMASTER_ADDRESS = '0x8a71416F2BCBd428c3Fc4284404617B139C0181C'
const provider = new Provider(RPC_URL);
const signer = new Wallet(PRIVATE_KEY, provider);
const contract = new Contract(CONTRACT_ADDRESS, CONTRACT_ABI, provider)
// method: approve, swap
// ACCOUNT: public address
const populateContract = await contract.populateTransaction[method](...params, {
from: ACCOUNT,
});
const gasLimit = await provider.estimateGas({ ...populatedTx, from: ACCOUNT });
const gasPrice = await provider.getGasPrice();
// TOKEN_ADDRESS: token pay gas erc20
const paymasterParams = utils.getPaymasterParams(PAYMASTER_ADDRESS, {
type: "ApprovalBased",
TOKEN_ADDRESS,
minimalAllowance: ethers.BigNumber.from(1),,
innerInput: new Uint8Array(),
});
populatedTx.customData = {
gasPerPubdata: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT
paymasterParams,
};
const sentTx = await signer.sendTransaction({
...populatedTx,
maxFeePerGas: gasPrice,
maxPriorityFeePerGas: BigNumber.from(0),
gasLimit,
});Last updated