Sponsored transactions

Before you can start sponsoring gas, you must deploy a paymaster contract. The paymaster MUST be staked & should have enough deposit to sponsor for gas. If the deposited amount becomes lesser than the gas required then your transactions will start failing.

Paymaster is a contract that sponsors gas fees on behalf of users. To know more about how it works, read in the architecture section.

Integration example

You will have to connect your paymaster with the SCW you created.

Sponsored transaction

import { PaymasterAPI } from '@openfort-sdk/scw';
const paymasterAPI = new PaymasterAPI('https://api.openfort.xyz','YOUR_SECRET_KEY');
// Connect your paymaster to the provider
scwProvider.connectPaymaster(paymasterAPI);
// Do transaction as normal
const scwSigner = scwProvider.getSigner();
const greeter = new ethers.Contract(
  GREETER_ADDR,
  GreeterArtifact.abi,
  scwSigner
);
const tx = await greeter.addGreet({
  value: ethers.utils.parseEther('0.0001'),
});
console.log(tx);
//Disconnect if you don't want to sponsor any further
scwProvider.disconnectPaymaster();

Example

Example implementation: Sponsored transaction integration