Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Pay gas fees with ERC20 tokens

This guide covers configuring gasless transactions where users pay gas using an ERC20 token. Choose between dynamic or fixed-rate payment strategies.

Charge an ERC20 with dynamic price

Step 1: Select the contract you want to interact with

  • Add your collectible's smart contract.
  • Define the contract function you want to use, for example mint.

Step 2: Set up a dynamic ERC20 policy

  • Create a new policy and select the strategy charge dynamic amount of ERC20.
  • Select the ERC20 token contract and exchange rate.
  • Link the imported contract and the function you want to sponsor.

Step 3: Create a gasless transaction

  • Add chainId.
  • Add the contract.
  • Add the policy.
  • Add the function you want to interact with.
Terminal
curl https://api.openfort.io/v1/transaction_intents \
  -u "$YOUR_SECRET_KEY:" \
  -d 'chainId=80002' \
  -d 'optimistic=true' \
  -d 'policy=policy_id' \
  -d 'interactions[0][contract]=contract_address' \
  -d 'interactions[0][functionName]=mint' \
  -d 'interactions[0][functionArgs][0]=sender_address_or_id'

Step 4: (Optional) Add the account or user

  • Add an account or user identifier.
Terminal
curl https://api.openfort.io/v1/transaction_intents \
  -u "$YOUR_SECRET_KEY:" \
  -d 'chainId=80002' \
  -d 'policy=policy_id' \
  -d 'account=account_id' \
  -d 'optimistic=true' \
  -d 'interactions[0][contract]=contract_address' \
  -d 'interactions[0][functionName]=mint' \
  -d 'interactions[0][functionArgs][0]=sender_address_or_id'

Charge an ERC20 with fixed price

Step 1: Select the contract you want to interact with

  • Add your collectible's smart contract.
  • Define the contract function you want to use, for example mint.

Step 2: Set up a fixed ERC20 policy

  • Create a new policy and select the strategy charge fixed amount of ERC20.
  • Specify the ERC20 token contract and the fixed amount to charge.
  • Link the imported contract and the function you want to sponsor.

Step 3: Create a gasless transaction

  • Add chainId.
  • Add the contract.
  • Add the policy.
  • Add the function you want to interact with.
Terminal
curl https://api.openfort.io/v1/transaction_intents \
  -u "$YOUR_SECRET_KEY:" \
  -d 'chainId=80002' \
  -d 'optimistic=true' \
  -d 'policy=pol_...' \
  -d 'interactions[0][contract]=con_...' \
  -d 'interactions[0][functionName]=mint' \
  -d 'interactions[0][functionArgs][0]=sender address or Id'

Step 4: (Optional) Add the account or user

  • Add an account or user identifier.
Terminal
curl https://api.openfort.io/v1/transaction_intents \
  -u "$YOUR_SECRET_KEY:" \
  -d 'chainId=80002' \
  -d 'policy={{POLICY_ID}}' \
  -d 'account={{ACCOUNT_ID}}' \
  -d 'optimistic=true' \
  -d 'interactions[0][contract]={{CONTRACT_ID}}' \
  -d 'interactions[0][functionName]=mint' \
  -d 'interactions[0][functionArgs][0]={{SENDER_ADDRESS}}'
Copyright © 2023-present Alamas Labs, Inc