Two Addresses
Our goal in this lesson is to create two blockchain addresses, and load one with funds.
We will move the funds in the following lessons.
We will be using (devnet) Solana in this example, as a faucet is readily available.
Verify that the treasury
tool is configured:
- CLI
treasury config treasury
should have output similar to
name = "treasuries/<treasury-id>"
api_url = "<api-url>"
sign_with = "client-keys/root-key"
Create an Address
Start the interpreter with treasury script
.
You should see:
::
This is your prompt to enter Cordial Scripting Language (CSL) commands.
In the remainder of the tutorial, code blocks titled with "CSL" should be copied into the CSL interpreter.
You can restart the interpreter by typing treasury script
in a terminal, in case you fall out it.
Run the following command:
- CSL
funded = create internal address for SOL
internal address CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A for SOL { version = 1, key = "keys/4", address = "CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A" }
Your actual address will differ here and in all that follows.
In the output, the part address CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A for SOL
is the "name" of the address. Name has a reserved meaning in Treasury: Everything in treasury has a globally unique name. Names are used as both primary keys and foreign keys within Cordial Treasury.
What happened in the background is that:
- a HTTP request (signed with your
root-key
from setup) was sent to the treasury. - the signer attached to treasury created a cryptographic keypair, and
- the engine component of treasury derived an address on Solana, backed by this generated keypair.
Load Funds
Visit https://faucet.solana.com/ in your browser, make sure "devnet" is selected, copy-paste the address you generated, and request an airdrop for 5 SOL.
To confirm, visit https://explorer.solana.com/?cluster=devnet in your browser, copy-paste the address you generated, and after some small delay the funds should appear.
Let's put a description on the address, so we can easily distinguish it. Run:
- CSL
update $funded { notes.description = "Funded address" }
internal address CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A for SOL { version = 2, notes = { description = "Funded address" }, key = "keys/4", address = "CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A" }
Note that the "version" of the address incremented by one, and the address now has a "description" note.
Second Address
To move funds, we need an additional address. So run:
- CSL
unfunded = create internal address for SOL { notes.description = "Unfunded address" }
internal address Vihj2YEBxvbAJM6iSxDAGC1ANESmGsiStdk8cJquJfW for SOL { version = 1, notes = { description = "Unfunded address" }, key = "keys/5", address = "Vihj2YEBxvbAJM6iSxDAGC1ANESmGsiStdk8cJquJfW" }
Your actual address will differ here and in all that follows. Note that we immediately set a description label in this case.
Explore Addresses
To confirm we now have two addresses, run the CSL command that lists all addresses in the treasury:
- CSL
addresses
internal address B2ZpkTJJqvL6KDaBD8DjVtPcEypHQnXLopUSFXCxdDCH for SOL { version = 1, notes = { description = "Unfunded address" } }
internal address CirHy2hKuR3Yajy5K6qXo4xEkobftHCFNJKQswswdc1A for SOL { version = 2, notes = { description = "Funded address" } }
The treasury you are connected to may have (many) other addresses (generated by yourself or by other users).
To list only addresses on the Solana blockchain, run the CSL command:
- CSL
addresses for SOL
In both of these lists, you should be able to find at least one address with the "description" note set to "Funded address", and at least one address having it set to "Unfunded address".