Execute your first transaction on Starcoin
This article guides you on how to execute your first transaction on the Starcoin blockchain. Before that, I recommend you read tech-related articles to get some idea of the basic concepts of Starcoin.
Let's say you've run up a Starcoin dev node locally.
A few steps to submit a transaction
- Start the Starcoin CLI console and connect to the Starcoin node，detail document at How working with the Starcoin console.
- Create two accounts: Alice and Bob, detail step see Manage account by CLI.
- Mint money into Alice's account.
- Submit transfer transaction: Alice send money to Bob.
Create an account
After connecting to the node, let's first create two accounts. Here we assume that both accounts have been created successfully.
Alice is the default account with the address
0xf096a2a61d3042774187a462a5394537 and Bob's address is
Use Faucet to top up your account
In dev environment, faucet can be used to mint accounts.
Faucet only exists in
test net to make it easier for developers developing and testing dapps.
Let's do it!.
starcoin% dev get-coin -v 100STC
dev get-coin will mint some coins the default account, and if the account does not exist on the chain, it will creates the account first and then transfers a specified (with
-v) number of coins to the account.
The output of the command is the transaction data issued by the FAUCET account (address
Wait a few seconds and then check your account information again.
starcoin% account show 0xf096a2a61d3042774187a462a5394537
sequence_number is filled.
First you need to unlock Alice's account and authorize node to sign the transaction using Alice's private key.
starcoin% account unlock -p <MY-PASSWORD> 0xf096a2a61d3042774187a462a5394537
-p option specifies
<MY-PASSWORD> is the password that was needed when creating the account, if the default account's init password is empty.
Once the account is unlocked, execute the following command:
starcoin% account transfer -s 0xf096a2a61d3042774187a462a5394537 -r 0xbabb67fa74c24466c500e642c79437de -v 10000 -b
-s 0xf096a2a61d3042774187a462a5394537: is Alice's account address.
-r 0xbabb67fa74c24466c500e642c79437de: is Bob's account address.
If, Bob's account does not yet exist on the chain, the transfer transaction will automatically create Bob's account on the chain.
At this point, the transaction has been submitted to the chain.
You still need to wait a few seconds (
dev environment block time is relatively short, maybe longer in
test environment) to let the transaction included the chain.
Then check Bob's account information again:
starcoin% account show 0xbabb67fa74c24466c500e642c79437de
Bob has the money now!
At this point, you have successfully completed an on-chain transfer.