Skip to main content

Fees, Gas, and Gasless Transactions

Freemium Gasless Model

Wonder introduces a freemium gasless model, allowing a paymaster to cover gas fees for most basic transactions. This model enables seamless onboarding and eliminates the need for users to hold native tokens, or bridged gas tokens for transaction fees.

How It Works

  1. Premium users executing complex transactions will pay gas fees that are pooled in a paymaster account.
  2. Free users submit transactions without paying gas fees.
  3. Transactions are relayed and sponsored by the paymaster's gas pool.

How to Use

SDK setup

npm install @wonderchain/sdk zksync-ethers

Or with yarn:

yarn add @wonderchain/sdk zksync-ethers

Initialize SDK

import { Configuration, NetworkApi } from "@wonderchain/sdk";

const apiHost = 'https://api.wonderchain.org';

const config = new Configuration({
basePath: apiHost,
});
const networkApi = new NetworkApi(config);

Interacting with Paymaster for Gasless transactions

import { Configuration, NetworkApi, Faucet__factory } from "@wonderchain/sdk";
import { Provider, utils, Wallet } from "zksync-ethers";

const apiHost = 'https://api.wonderchain.org';

// testnet config
const chainId = 96371;
const rpcUrl = 'https://rpc.testnet.wonderchain.org';


const provider = new Provider(rpcUrl);

// or use a browser wallet
const privateKey = process.env.PRIVATE_KEY;
const wallet = new Wallet(, privateKey);

const config = new Configuration({
basePath: apiHost,
});
const networkApi = new NetworkApi(config);

const value = '0x';
const data = '0x';
const paymasterParams = await networkApi.paymasterParams(
chainId,
wallet.address,
to,
value,
(await wallet.getNonce()).toString()
);

// broadcast the transaction
const tx = await wallet.sendTransaction({
to,
from: wallet.address,
data,
value,
customData: {
paymasterParams: utils.getPaymasterParams(paymasterParams.data.data.address, {
type: "General",
innerInput: paymasterParams.data.data.signature,
}),
}
});
const receipt = await tx.wait();
console.log(receipt);

Interacting with Faucet (Testnet Only)


import { Configuration, NetworkApi, Faucet__factory } from "@wonderchain/sdk";
import { Provider, utils, Wallet } from "zksync-ethers";

const apiHost = 'https://api.wonderchain.org';

// testnet config
const chainId = 96371;
const rpcUrl = 'https://rpc.testnet.wonderchain.org';


const provider = new Provider(rpcUrl);

// or use a browser wallet
const privateKey = process.env.PRIVATE_KEY;
const wallet = new Wallet(, privateKey);

const config = new Configuration({
basePath: apiHost,
});
const networkApi = new NetworkApi(config);

// using faucet (testnet only)
const faucetParams = await networkApi.faucetParams(chainId, wallet.address);
const paymasterParams = await networkApi.paymasterParams(
chainId,
wallet.address,
faucetParams.data.data.address,
"0", // replace with value for
(await wallet.getNonce()).toString()
);


// example abi to connect
const faucet = Faucet__factory.connect(faucetParams.data.data.address, provider);

// hydrate the transaction with paymaster parameters
const data = await faucet.drip.populateTransaction(faucetParams.data.data.signature, {
type: utils.EIP712_TX_TYPE,
from: wallet.address,
chainId: (await provider.getNetwork()).chainId,
customData: {
paymasterParams: utils.getPaymasterParams(paymasterParams.data.data.address, {
type: "General",
innerInput: paymasterParams.data.data.signature,
}),
},
});

// broadcast the transaction
const tx = await wallet.sendTransaction(data);
await tx.wait();