REST backend service that enables browser-extension wallets to upgrade an EOA (Externally Owned Account) to an EIP-7702 Account Abstraction smart-contract wallet on Conflux eSpace.
The service includes three major capability groups:
- EIP-7702 Account Abstraction upgrade
- Gas Tank paymaster signing flow
- Token Pay sponsored transaction flow
For account-abstraction upgrade, the service accepts a pre-signed EIP-7702 authorization message from the wallet, broadcasts the corresponding type-4 set-code transaction using its own fee-payer account, and lets the wallet poll for the on-chain result. So, the user's EOA never needs to hold native tokens for gas.
For Gas Tank and Token Pay, the service helps clients estimate/sign/pay gas in ERC20-denominated flows.
Please refer to .env.example file to prepare a .env file for service configurations.
At minimum, make sure you configure:
- RPC endpoint and sponsor private key (service signer)
- EIP-7702 delegated contract (optional restriction)
- Gas Tank paymaster address
- Token Pay recipient and supported token list
# Build
go build
# Run (auto load .env file)
./fluent-backendPOST /api/aa/auth: submit a signed EIP-7702 authorizationGET /api/aa/auth/:txHash: query execution status/result
Gas Tank APIs help wallet clients prepare and sign paymasterData for UserOperation.
POST /api/aa/gastank/prepare/credit- Prepare
paymasterDatafor CREDIT mode (deposit flow)
- Prepare
POST /api/aa/gastank/prepare/refund- Prepare
paymasterDatafor REFUND mode (spend existing Gas Tank balance)
- Prepare
POST /api/aa/gastank/sign- Calculate
maxTokenCost, sign paymaster payload, and return finalpaymasterData
- Calculate
Typical wallet flow:
- Call
prepare/creditorprepare/refund. - Put returned
paymasterDatainto UserOperation and estimate gas. - Call
signwith estimated UserOperation. - Replace UserOperation paymaster data with returned signed payload and submit.
Token Pay lets users submit two signed txs while backend sponsors native gas:
- tx A: transfer ERC20 token to backend recipient (gas payment)
- tx B: user business transaction
APIs:
GET /api/tokenpay/config- Return supported tokens, recipient, and gas/price policy params
GET /api/tokenpay/price?token=0x...- Return token units equivalent to 1 ETH (integer in token smallest unit)
POST /api/tokenpay/submit- Submit both signed raw txs:
rawTransferTokenTxandrawBusinessTx
- Submit both signed raw txs:
Submit behavior:
- Backend validates both signed raw txs.
- Backend sends funding ETH tx from sponsor account.
- After funding confirms, backend broadcasts transfer-token tx then business tx.
- Completion is considered successful only when both transactions execute successfully.
There are some business errors for wallet to handle, see all defined errors on github.
A built-in auth sub-command generates and prints a signed EIP-7702 authorization message, useful for testing:
./fluent-backend auth \
--url https://evmtestnet.confluxrpc.com \
--key 0x<YOUR_PRIVATE_KEY> \
--contract 0x<DELEGATED_CONTRACT_ADDRESS>The output is a JSON object ready to POST to /api/aa/auth.
Warning: Pass your private key via an environment variable or a secrets file in production to avoid shell history exposure.
A built-in test-token-pay sub-command performs an end-to-end token-pay test flow:
./fluent-backend test-token-pay \
--backend https://api-testnet.fluentwallet.com/api \
--rpc https://evmtestnet.confluxrpc.com \
--key 0x<FAUCET_PRIVATE_KEY>It will:
- Create a random test account
- Faucet supported token to that account
- Build transfer-token/business tx pair
- Simulate both txs
- Submit to
/api/tokenpay/submit - Wait for business tx receipt
When api.swaggerEnabled: true, the interactive Swagger UI is available at swagger/index.html.