Etherbase

For SKALE chains launched after April 2022, the Etherbase predeployed contract stores and manages sFUEL received from block rewards and spent gas fees. At deployment, the SKALE Chain owner is assigned as the DEFAULT_ADMIN_ROLE and ETHER_MANAGER_ROLE. The owner can transfer these roles to other accounts, multisigs, or contracts.

For more information about Etherbase including the predeployed address, initial distribution amounts, and distribution functions see Etherbase Permissions

Etherbase Solidity usage example

The following example illustrates how you can incorporate an automatic top-up modifier to ensure users have sufficient sFUEL to transact.

Example assumes that users have already been provisioned some initial sFUEL.
pragma solidity ^0.8.0;

interface IEtherbase {
    receive() external payable;
    function retrieve(address payable receiver) external;
    function partiallyRetrieve(address payable receiver, uint amount) external;
}

contract EtherbaseUsage {

    uint256 MIN_AMOUNT = 1000000000000000;

    modifier topUp {
        if (msg.sender.balance < MIN_AMOUNT) {
            partiallyRetrieve(payable(msg.sender), MIN_AMOUNT);
        }
        _;
    }

    function retrieve(address payable receiver) public {
        getEtherbase().retrieve(receiver);
    }

    function partiallyRetrieve(address payable receiver, uint amount) public {
        getEtherbase().partiallyRetrieve(receiver, amount);
    }

    function sendToEtherbase() public payable {
        getEtherbaseAddress().transfer(msg.value);
    }

    function getEtherbase() public pure returns (IEtherbase) {
        return IEtherbase(getEtherbaseAddress());
    }

    function getEtherbaseAddress() public pure returns (address payable) {
        return payable(0xd2bA3e0000000000000000000000000000000000);
    }
}

contract YourContract is EtherbaseUsage {

    function yourFunction(address payable receiver, uint amount) external payable topUp {
        partiallyRetrieve(receiver, amount);
        retrieve(receiver);
        sendToEtherbase();
    }
}
YourContract example above must be granted with ETHER_MANAGER_ROLE.

For further develop details on distributing and developing with sFUEL, see Access Control.