Integration
Swapping and Aggregation
EVM Integration
StateChain Gateway

Fund and redeem via State Chain Gateway

As explained in the State Chain Overview, the StateChainGateway contract has two main entry points for those looking to interact with the protocol:

  1. Funding a State Chain account with $FLIP tokens
  2. Redeeming $FLIP tokens from a State Chain account

Funding a State Chain account

Users can fund a State Chan account by making a smart contract call and providing an amount of $FLIP to be locked in the contract. Tokens need to be approved first by the user to be transferred by the contract.

ParamDescriptionData type
nodeID`ChainflipAccountID` (a hex representation of a substrate SS58 encoded public key) of the account to fund.bytes32
amountAmount of $FLIP tokens to fund. The amount needs to be higher than the minimum funding amount, set to 1 $FLIP as of now.uint256
    function fundStateChainAccount(bytes32 nodeID, uint256 amount) external;

Redeeming from a State Chain account

After the user has submitted a redemption request to the State Chain, the protocol will submit the redemption to the State Chain Gateway. The contract will store it as a Redemption struct. The redemption is considered to be pending and can be checked with the view function below.

ParamDescriptionData type
amountAmount of $FLIP tokens redeemeduint256
redeemAddressEthereum address that will receive the redeemed $FLIPaddress
startTimeStarting timestamp in which the Redemption can be executeduint48
expiryTimeTimestamp in which the redemption expires and can't be executed anymoreuint48
executorAddress that can execute the redemption. By default any address can execute any redemption.address
    struct Redemption {
        uint256 amount;
        address redeemAddress;
        uint48 startTime;
        uint48 expiryTime;
        address executor;
    }
 
    function getPendingRedemption(bytes32 nodeID) external view returns (Redemption memory);

As previously explained, the fail-safe mechanism adds a 2-day delay between the registry of the redemption and the time when it can be executed. After that delay and until the expiry time, the redemption can be executed to complete the redemption process. In the event of the redemption having specified an executor address, only that address can execute the redemption. Otherwise, any address can execute it.

The protocol doesn't automatically execute the redemptions, the user needs to make smart contract call below specifying the nodeID of the account following the same format as the funding function.

    function executeRedemption(bytes32 nodeID) external returns (address, uint256);
;