Execute commands
Now we complete the task - sending some tokens that have been delegated to a key
Running commands
As mentioned in the introduction, now we want to:
As the admin key (A)†, set an allowance for a key (B)
As the key with an allowance, send tokens from key (B) to key (C)
See tokens arrive at key (C)
See allowance decrease for key (B)
† this is the key that you used to instantiate, and set as an admin. If you are running a validator in the testnet, then it is probably your self-delegate key.
1. Add allowance for key B
Using node
, you can again encode the following arguments:
Then, as the admin key (A), increase key (B)'s allowance:
If you query its allowance, you should see a value of 2000000
:
Should return:
2. Send tokens from key B to key C
First, query the balance of another key, that we did not allocate any tokens to (C):
Let's say it already has a balance of 500usource
- the command will return:
Then, we again need to encode some arguments to JSON for the send:
Once we have the JSON, we can shape an execute
command:
Note that the --from
flag is now signing this from the key (B) that the admin key (A) gave a token balance to. This CW1 Subkeys contract will only work with the native token of the chain, in this case usource
.
3. Check balance of key C
If we query balance again:
We expect to see the balance incremented by 500usource
:
4. See allowance decrease for key B
Now, if we query the allowance for key B, we should see it has decreased by 500usource
:
We're done!
Play around some more with increasing and decreasing allowances, or even adding expiries to allowances, to get a better feel for how this works.
Last updated