Withdrawal

The withdrawal process in the Avail network using the Staking API can be done following these steps:

  1. Create Unbond Request: unbond tokens within the Avail network that were previously staked or bonded.

It takes 28 days to unbond on Avail mainnet.

  1. Withdraw Unbonded Request: withdraw tokens within the Avail network that were previously unbonded. Note that this request is available after the unbond period.

Staking directly

1. Create Unbond Request

  1. Send a POST request to /api/v1/avail/{network}/staking/direct/unbond.

    Example request (for testnet):

    curl --request POST \
         --url https://api.p2p.org/api/v1/avail/testnet/staking/unbond \
         --header 'accept: application/json' \
         --header 'authorization: Bearer <token>' \
         --header 'content-type: application/json' \
         --data '
    {
      "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5",
      "amount": 1000
    }'
    
    • stashAccountAddress — main stash account address which keeps tokens for bonding.
    • amount — amount of tokens to unbond. AVAIL is used for the mainnet network.

    Example response:

    {
      "result": {
        "unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f",
        "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5",
        "amount":1000,
        "createdAt": "2023-08-15T15:07:54.795Z"
      }
    }
    
    • unsignedTransactionunsigned transaction in hex format. Sign the transaction and submit it to the blockchain to perform the called action.
    • stashAccountAddress — main stash account address which keeps tokens for bonding.
    • amount — amount of tokens for bond operations. AVAIL is used for the mainnet network.
    • createdAt — timestamp of the transaction in the ISO 8601 format.
  2. Sign and broadcast the unsignedTransaction to the Avail network.

2. Withdraw Unbonded Request

  1. Send a POST request to /api/v1/avail/{network}/staking/direct/withdraw-unbonded.

    Example request (for testnet):

    curl --request POST \
         --url https://api.p2p.org/api/v1/avail/testnet/staking/withdrawal-unbonded \
         --header 'accept: application/json' \
         --header 'authorization: Bearer <token>' \
         --header 'content-type: application/json' \
         --data '
    {
      "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5"
    }'
    
    • stashAccountAddress — main stash account address which keeps tokens for bonding.

    Example response:

    {
      "result": {
        "unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f",
        "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5",
        "createdAt": "2023-08-15T15:07:54.795Z"
      }
    }
    
    • unsignedTransaction — unsigned transaction in hex format. Sign the transaction and submit it to the blockchain to perform the called action.
    • stashAccountAddress — main stash account address which keeps tokens for bonding.
    • createdAt — timestamp of the transaction in the ISO 8601 format.
  2. Sign and broadcast the unsignedTransaction to the Avail network.

Staking via a nomination pool

1. Create Unbond Request

  1. Send a POST request to /api/v1/avail/{network}/staking/pool/unbond.

    Example request (for testnet):

    curl --request POST \
      --url https://api.p2p.org/api/v1/avail/testnet/staking/pool/unbond \
      --header 'accept: application/json' \
      --header 'authorization: Bearer <token>' \
      --header 'content-type: application/json' \
      --data '
    {
    "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5",
    "amount": 3
    }'
    
    • stashAccountAddress — main stash account address which keeps tokens for bonding.
    • amount — amount of tokens to unbond. AVAIL is used for the mainnet network.

    Example response:

    {
    "result": {
     "unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f",
     "amount": 3,
     "createdAt": "2023-08-15T15:07:54.795Z"
    }
    }
    
    • unsignedTransactionunsigned transaction in hex format. Sign the transaction and submit it to the blockchain to perform the called action.
    • amount — amount of tokens for bond operations. AVAIL is used for the mainnet network.
    • createdAt — timestamp of the transaction in the ISO 8601 format.
  2. Sign and broadcast the unsignedTransaction to the Avail network.

2. Withdraw Unbonded Request

  1. Send a POST request to /api/v1/avail/{network}/staking/pool/withdraw-unbonded.

    Example request (for testnet):

    curl --request POST \
      --url https://api.p2p.org/api/v1/avail/testnet/staking/withdrawal-unbonded \
      --header 'accept: application/json' \
      --header 'authorization: Bearer <token>' \
      --header 'content-type: application/json' \
      --data '
    {
    "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5",
    "poolId": "45"
    }'
    
    • stashAccountAddress — main stash account address which keeps tokens for bonding.
    • poolId — ID of the nomination pool in which you participate in.

    Example response:

    {
    "result": {
     "unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f",
     "createdAt": "2023-08-15T15:07:54.795Z"
    }
    }
    
    • unsignedTransaction — unsigned transaction in hex format. Sign the transaction and submit it to the blockchain to perform the called action.
    • createdAt — timestamp of the transaction in the ISO 8601 format.
  2. Sign and broadcast the unsignedTransaction to the Avail network.

What's Next?