Skip to main content

Move Funds: Success!

From the previous lesson, we should have two addresses tied to variables:

$funded
Output
internal address CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A for SOL { version = 2, notes = { description = "Funded address" } }

and

$unfunded
Output
internal address Vihj2YEBxvbAJM6iSxDAGC1ANESmGsiStdk8cJquJfW for SOL { version = 1, notes = { description = "Unfunded address" } }

If not, revisit the previous lesson to create and/or bind the addresses to these variables.

Transfer Policy

At any point in time, Treasury has a Transfer Policy in place, which consists of a collection of Transfer Rules. Such rules come in multiple variants (allow, require, deny), but in this tutorial we will only deal with "allow" rules. Recall that Treasury by default denies transfers that are not explicitly allowed.

Let's allow the transfer that previously failed, by creating an allow transfer rule:

create allow transfer rule { from = $funded, to = $unfunded, asset = "SOL" }
Output
active allow transfer-rule 8 { version = 1, asset = "chains/SOL/assets/SOL", from = "chains/SOL/addresses/CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A", to = "chains/SOL/addresses/Vihj2YEBxvbAJM6iSxDAGC1ANESmGsiStdk8cJquJfW" }

Our transfer policy is now non-empty, which you can confirm by querying it:

transfer policy
Output
active allow transfer-rule 8 { version = 1, asset = "chains/SOL/assets/SOL", from = "chains/SOL/addresses/CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A", to = "chains/SOL/addresses/Vihj2YEBxvbAJM6iSxDAGC1ANESmGsiStdk8cJquJfW" }

Your First Cordial Transfer

With an applicable transfer policy in place, our transfer should now succeed:

my-transfer = create transfer { from = $funded, to = $unfunded, asset = "SOL", amount = "1" }
Output
preparing transfer 9 { version = 1, from = "chains/SOL/addresses/CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A", to = "chains/SOL/addresses/Vihj2YEBxvbAJM6iSxDAGC1ANESmGsiStdk8cJquJfW", asset = "chains/SOL/assets/SOL", amount = "1", last_transaction "transfers/9/transactions/10" }

You can visit https://explorer.solana.com/?cluster=devnet to inspect the two addresses, eventually the transfer should succeed.

Also, you can repeatedly query the transfer in the interpreter to track progress:

$my-transfer
Output
finalizing transfer 9 { version = 1, from = "chains/SOL/addresses/CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A", to = "chains/SOL/addresses/Vihj2YEBxvbAJM6iSxDAGC1ANESmGsiStdk8cJquJfW", asset = "chains/SOL/assets/SOL", amount = "1", last_transaction = "transfers/9/transactions/10" }

and eventually

$my-transfer
Output
succeeded transfer 9 { version = 1, from = "chains/SOL/addresses/CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A", to = "chains/SOL/addresses/Vihj2YEBxvbAJM6iSxDAGC1ANESmGsiStdk8cJquJfW", asset = "chains/SOL/assets/SOL", amount = "1", last_transaction = "transfers/9/transactions/10" }

The transfer should go through the states "preparing", "signing", "submitting", "finalizing", and end up in the state "succeeded".