Developer Reference
Gas and Fee Architecture
Pre-launch
Section
Developer Reference
Documentation category
Type
Guide
Technical reference
Summary
EIP-1559 gas mechanics on SwssChain: fee estimation, deed transaction priority, gas optimisation techniques, and EIP-1153 transient storage usage.
SWSS Foundation Notice

This documentation is restricted to authorised members of the SWSS Developer Community. Access is granted exclusively through SWSS DevHub, after KYB and SWSS Foundation approval.

All SwssChain GitHub repositories are private. Significant updates are currently deploying across the full SWSS Ecosystem. SDK and API specifications are subject to change at any time in accordance with security requirements and SwssChain Foundation governance decisions.

Join SWSS DevHub →Have a question? Use the Need Help? button below.
SDK Update Notice

SWSS SDK v2.1 is deploying across the ecosystem. API signatures may change during this period. Ensure your integration uses the latest schema from SWSS DevHub.

Article Content

Gas and Fee Architecture

All gas fees on SwssChain are denominated in SWSS Coin. The fee mechanism follows the EIP-1559 model (base fee, priority fee, and maximum fee) with a SwssChain-specific modification for deed transaction priority processing. For standard smart contract interactions, the EIP-1559 model works identically to Ethereum: unused gas is refunded, the base fee adjusts per block based on network utilisation, and the priority fee is an optional tip to validators.

EIP-1559 on SwssChain

Fee ComponentDescriptionNotes
Base FeeAlgorithmically adjusted per block based on utilisationPartially retired via TSL for deed transactions
Priority FeeOptional tip paid directly to the validatorLower competition than Ethereum: 1-second blocks reduce urgency
Max FeeMaximum total fee (base + priority) you are willing to paySet via maxFeePerGas in transaction
RefundUnused gas is refunded to senderIdentical to Ethereum behaviour

Deed Transaction Fee Priority

Deed transactions pay a higher base fee than standard transactions. This elevated fee activates the Transactional Settlement Levy at the consensus layer, permanently retiring a micro-fraction of SWSS Coin supply. Importantly, SAPE guarantees deed transactions first-position processing in every block regardless of fee level, the priority lane is protocol-enforced, not fee-enforced. Standard fee competition does not apply to deed transaction ordering.

Estimating Gas with ethers.js

import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider(process.env.SWSSCHAIN_RPC_URL);
const contract = new ethers.Contract(contractAddress, abi, provider);

// Estimate gas for a specific function call
const gasEstimate = await provider.estimateGas({
  to: contractAddress,
  data: contract.interface.encodeFunctionData('myFunction', [arg1, arg2])
});

// Get current fee data
const feeData = await provider.getFeeData();

// Estimate cost in SWSS Coin
const estimatedCost = gasEstimate * feeData.gasPrice;
console.log('Estimated cost (SWSS):', ethers.formatEther(estimatedCost));

Sending a Transaction with Explicit Gas Settings

const signer = await provider.getSigner();
const contractWithSigner = contract.connect(signer);

const tx = await contractWithSigner.myFunction(arg1, arg2, {
  gasLimit: (gasEstimate * 120n) / 100n,   // 20% buffer
  maxFeePerGas: feeData.maxFeePerGas,
  maxPriorityFeePerGas: feeData.maxPriorityFeePerGas
});

const receipt = await tx.wait();
console.log('Confirmed in block:', receipt.blockNumber);

Gas Optimisation on SwssChain

The 1-second block time significantly reduces the need for elevated priority fees. On Ethereum, a higher priority fee is often necessary to avoid waiting multiple blocks during periods of congestion. On SwssChain, the next block is always one second away: standard priority fees are sufficient in all but the most extreme load scenarios.

EIP-1153 transient storage (TSTORE/TLOAD) is available and recommended for reentrancy guards and flash loan patterns. Transient storage costs significantly less than permanent storage and is automatically cleared at the end of the transaction.

// Using transient storage for a reentrancy lock (Solidity 0.8.24+)
// tstore(slot, value) / tload(slot) are available via assembly
contract ReentrancyGuarded {
    uint256 private constant LOCK_SLOT = 1;

    modifier nonReentrant() {
        assembly { if tload(LOCK_SLOT) { revert(0, 0) } }
        assembly { tstore(LOCK_SLOT, 1) }
        _;
        assembly { tstore(LOCK_SLOT, 0) }
    }
}

Next Steps