infra-cli
1.) The simplest way for us to interact with the Telos blockchain is by using the infra-cli
software from the InfraBlockchain-Antelope repository. Follow their installation instructions.
2.) Once installed, you can confirm that infra-cli
has been installed correctly by simply typing infra-cli --help
from the command line. If infra-cli
is properly installed, then you will see helpful information on how to call the program from the terminal.
3.) In order to obtain useful and up-to-date information about the state of the blockchain, we will need to request the data from a Block Producer's node. In this case we'll be using the following base URL: https://testnet.telos.caleos.io
Execute the following command from your terminal, with myAccountName
replaced by your actual InfraBlockchain-Antelope Testnet account name: infra-cli -u https://testnet.infrablockchain.io get account myAccountName
. If your endpoint is up-to-date and your account is activated then you should see output like the following in your terminal:
First, let's take a moment to understand the "action" and "transaction" terminology utilized by the Telos blockchain, as well as cryptocurrency as a whole. First generation cryptocurrencies like Bitcoin were focused on the storage and transfer of the chain's native tokens (BTC), with the blockchain primarily being used as a ledger storing addresses and transaction inputs + outputs. With the rise of Ethereum and other general-purpose blockchains the type of data that can be stored has opened up to store many more types of data including strings, vectors, maps, enums, timestamps, and custom types. The types of "transactions" that can be executed on the Telos blockchain is nearly limitless. "Actions" refer to the atomic procedures that can be executed through a smart contract on the blockchain, and "transactions" refers to a grouping of multiple actions that can be executed atomically (all completed successfully or none completed at all, no partial execution).
As an example, the account creation transaction consists of three different actions:
eosio::newaccount: creates the account by executing the
newaccount
action on theeosio
account smart contracteosio::buyram: buys some ram for the account by executing the
buyram
action on theeosio
account smart contracteosio::delegatebw - stakes some CPU/NET for the account by executing the
delegatebw
action on theeosio
account smart contract
So don't let the transaction
vs action
terminology get you mixed up. Now, let's find the most recent actions related to our account.
4.) Execute the following code from your terminal to get a list of the most recent actions that have involved your account infra-cli -u https://testnet.infrablockchain.io get actions myAccountName
이하 내용 Faucet 적용된 내용 반영 or 삭제
Here you can see that my captaincrypt
account has received testnet faucet TLOS tokens on two occasions. This result is helpful but not as useful as if it were returned to us in JSON format. Let's enable the JSON option by executing the following from our terminal cleos -u https://testnet.telosusa.io get actions
--json
myAccountName
That's much better! Now we have a format that shows all of the information and in a format that can be consumed by most software.
Now that we've seen what the data for a transaction looks like, it's time to try executing a transaction from our account. In this case we will try to send some Testnet TLOS tokens back to the faucet.tf
account from which we received them, with a note "Thanks for the free TLOS". Try executing the following commands from your terminal: cleos -u https://testnet.telosusa.io transfer myAccountName faucet.tf "1.0000 TLOS" "Thanks for the free TLOS!"
You may have ended up with the following error, a reminder that we have not yet established cleos
as the wallet for our TLOS account:
Fear not, we would be more concerned if cleos
were able to control our tokens without the private key! So let's create the wallet for controlling our testnet account.
5.) To link our cleos
software we will want to create a wallet, unlock it with the password, and import our private key (which we should be able to export from Scatter or SQRL). To create the wallet, execute the following from the command line: cleos wallet create --name telos-testnet-myAccountName --file telos-testnet-myaccountName.txt
This command tells cleos
to create a wallet called telos-testnet-myAccountName
and save the wallet password to the file telos-testnet-myAccountName.txt
in the current working directory. Please make sure that you do not lose this password because you will need it in order to execute token transfers in cleos
, and it will be inconvenient to have to create a new wallet if you lose the password.
If the command executes successfully, the file that you specified (telos-testnet-myAccountName.txt
) should now contain a password that is about 53-characters long and starting with PW.....
. Go ahead and copy that password as we will be using it in our next command: cleos wallet unlock -n telos-testnet-myAccountName --password PWmy53CharacterWalletPasswordasdfasasdfljpouewrlscad2342asf
This command unlocks the wallet and sets is as the currently active wallet (in the event that you have multiple wallets in cleos
). Next, we want to import the private key for your testnet account (which you should be able to export from Scatter or SQRL) to give this wallet control over our Telos Testnet account. Execute the following command into your terminal: cleos wallet import --name=telos-testnet-myAccountName --private-key 5KbSome51CharacterPrivateKey
You should see output in your console that looks something like the following: imported private key for: EOSsome53CharacterPublicKey
, signifying that your private key has been properly imported.
6.) Next, let's attempt to re-execute the token transfer that failed earlier, keep in mind that you may have to re-unlock your wallet if too much time has passed since you last used the wallet. If so, just re-execute the cleos wallet unlock
command from earlier: cleos -u https://testnet.telosusa.io transfer --json myAccountName faucet.tf "1.0000 TLOS"
If you have properly linked your private key and wallet then you should see JSON output that looks something like the following:
Congrats, you have properly executed a token transfer from your account back to the faucet.tf
account!
Last updated