Move Funds: First Attempt
From the previous lesson, you should have two Solana addresses available, which you can confirm
by running the CSL command addresses.
Variables
When we created the two addresses in the previous lesson, our command wasn't just create internal address...,
but we immediately tied the generated addresses to variables funded and unfunded.
Variables can be dereferenced with the $ sign, so for instance:
- CSL
$funded
internal address CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A for SOL { version = 2, notes = { description = "Funded address" } }
outputs the address tied to the variable funded.
If you drop out of the CSL interpreter, such variables are lost. In this case, you can create bind the variables again by typing
funded = address CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A for SOL
and
unfunded = address Vihj2YEBxvbAJM6iSxDAGC1ANESmGsiStdk8cJquJfW for SOL
in the interpreter, but using your actual addresses.
First Attempts
Let's try and move some SOL!
- CSL
create transfer { from = $funded, to = $unfunded, asset = "SOL", amount = 1 }
Invalid Argument: invalid type: integer `1`, expected a string in `amount`
Oops! That fails.
The reason is that amounts in Treasury are always represented as decimal strings. This is reflected in the syntax error, stating that a string was expected in the amount field, not the integer 1.
The correct command is (note the quotes around the number 1):
- CSL
create transfer { from = $funded, to = $unfunded, asset = "SOL", amount = "1" }
Permission Denied: 7: transfer policy did not pass
Oops! In this case, we received an error from the Treasury API, namely "Permission Denied". Treasury is setup to deny-by-default any transfer requests by which were not explicitly allowed.
Keep the interpreter open and proceed to the next lesson.