TON: From vesting contract to nominator

This guide would show you the following:

  1. How to create a vesting contract in TON network.
  2. How to join a single nominator pool with your vested token.

Important

Please make sure to test everything in the testnet before moving to the mainnet

How to create a vesting contract in TON network.

TON has provided a vesting manager for everything related to vesting contract.

Vesting Manager Mainnet: https://vesting.ton.org/ Vesting Manager Testnet: https://vesting.ton.org/?testnet=true Vesting Manager Website source code: https://github.com/ton-blockchain/vesting Vesting Contract source code: https://github.com/ton-blockchain/vesting-contract

1. Create a vesting contract

Note

In this section, everything is wrote in the perspective of a vesting sender/creator.

Before performing any other action, you should connect your wallet to this manager.

  1. After connected, it should look something like this (top right "Connect Wallet" replaced with your wallet address): 截屏2024-09-20 10 11 00

  2. Hence, paste the vesting receiver's wallet address in the search bar, hit enter, you should now be able to see this page: 截屏2024-09-20 10 12 10

  3. After clicking "Create new vesting for this user", fill the blanks with your desired parameters for this vesting: 截屏2024-09-20 10 15 13 The website will output a human readable version for all the parameters:


Essentially: Token will be locked for Total vesting duration days, after Cliff duration days, half of the token will be unlocked, then every Unlock period days, (Total vesting amount/2)/(Total vesting duration - Cliff duration) token will be unlocked.

  1. Click "Create", then confirm the contract call transaction in your wallet app. IMG_6371

Tip

Congrats! You have just created a vesting contract.

2. Nominate with vesting contract

Note

In this section, everything is wrote in the perspective of a vesting owner, (may or may not be the same human being with vesting creator/sender).

  1. Create a single nominator pool I assume that you already have a synced full node on the corresponding network environment, and the validator mode is activated, with sufficient balance in validator wallet (~200TON per month for validator to cover the transaction fees, this is NOT the minimum stake amount), if not, please checkout the official doc on how to run a full node: https://docs.ton.org/participate/run-nodes/full-node, and how to activate validator mode: https://docs.ton.org/participate/run-nodes/become-validator.

Note

If you wish not to become a node operator, and simply wants to become a nominator, then please reach out to someone who would do that for you and ask for the single nominator pool address. PLEASE PLEASE note that the node operator should follow the instructions below to create a single nominator pool and have the pool owner set to your VESTING CONTRACT WALLET ADDRESS, or else you would not be able to withdraw any token you deposited.

Once everything is prepared, go to mytonctrl, for this doc, I assume that this is freshly synced validator node, with only the validator mode is enabled: 截屏2024-09-20 10 38 30

Then, you should follow the official doc to create a single nominator pool and activate it: https://docs.ton.org/participate/network-maintenance/single-nominator

In short, it requires you to run the following command

enable_mode single-nominator
new_single_pool <pool-name> <owner_address, in our case, vesting contract address>
activate_single_pool <pool-name>

After everything is executed successfully, type in pools_list to make sure that the pool is activated: 截屏2024-09-20 10 43 16

In our example, kf8P4IIeig3dRx8LnvMvj5Tg707zvTvZP2BAV8iVJzH4JD_V is the single nominator pool address.

  1. Add single nominator pool address to vesting whitelist You must complete this step to allow the vesting contract to send any token to your single nominator pool. More about vesting whitelist can be found at: https://github.com/ton-blockchain/vesting-contract?tab=readme-ov-file#whitelist-restrictions

Ask the vesting creator/sender to do this for you, which should also verify the single nominator pool info is correct, specifically, owner should be your vesting contract wallet address, validator should be the local validator wallet of node that is running the single nominator pool. 截屏2024-09-20 10 46 08

After clicking add and confirming the contract call transaction as well as a small delay, you should see the single nominator pool address show up in the whitelist section: 截屏2024-09-20 10 49 49

  1. Stake token to single nominator pool For single nominator pool, staking token is as simple as sending token to single nominator pool, e.g.: 截屏2024-09-20 10 52 53 截屏2024-09-20 10 54 12

  2. Withdraw token from single nominator pool This step requires you to download the single nominator pool repo:

git clone https://github.com/orbs-network/single-nominator
cd single-nominator
npx ts-node@v10.7.0 scripts/ts/withdraw-deeplink.ts <single_nominator_pool_address> <withdraw amount>

This would generate you a deeplink, which contains a payload after ?bin=, i.e. te6cckEBAQEAFAAAIwAAEAAAAAAAAAAAAVAlQL5ACJyOKxw, as an example. 截屏2024-09-20 11 53 22

Now, we need to copy this payload, and get back the vesting manager, start a transaction:

Caution

Make sure to first paste the payload, and then select message type to BOC!!!

截屏2024-09-20 11 54 56

Click send, confirm on your wallet app, and wait for a bit, you should now be able to find the withdraw transaction from single nominator pool (withdraw amount + withdraw contract call fee (1 TON)): 截屏2024-09-20 11 58 42

Note

Token is withdrawn to the vesting contract, not to your own wallet.