Example configuration for testing Construction API (Ethereum similar blockchain)

Can anyone give me an example of rosetta-cli-check configuration file for Ethereum similar blockchain ?

:wave: @nguyennguyen

You can find an example for Ethereum-like blockchains here:

We already converted our example to use our new DSL too (already linked in the config example):

How can I specify the address (and its private key) which will make transfer transaction ?

The rosetta-cli handles this complexity for you. It generates new address, stores private keys, and selects accounts to perform transfers based on available balance automatically. When you write your config, you provide generic instructions that the rosetta-cli can execute. You can find our existing documentation on how to write these tests here:

Example Walkthrough

In the Ethereum transfer workflow example, you can see that we first attempt to find an account with a balance of at least 10000000000000000:

If no account exists, the rosetta-cli prompts us to run the create_account workflow to generate a keypair and address:

Next, it runs the request_funds workflow (so that funds can be deposited):

Once we have an address with funds, we continue to execute the transfer workflow. We select a recipient account and send a random amount of funds (we indicate that the recipient should not be equal to the sender)emphasized text:

Lastly, we specify the “intent” we wish to broadcast:

The rosetta-cli takes this intent and walks through the Construction API flow, creating signatures when necessary, and broadcasts the constructed transaction. If you are curious about how this all works, I recommend taking a look at the constructor package:

Example Video

If you are more of a visual learner (like me), this outdated video provides a nice example of what this looks like in action (creating accounts, constructing transactions, signing transactions, broadcasting transactions):

There is also a thread that discusses the design goals of this automated tester:

still not really clear
find_balance find a random account have fund at least 10000000000000000 but how can CLI script have private key of that account
request_funds function also didn’t specify any account with fund and private key

My blockchain started from genesis block with only one account that have funds. If I don’t specify key of that account to somewhere in rosetta-CLI configuration, I believe there is no way to test check:construction

In the linked example, accounts are created in the create_account workflow (which is called when needed by the rosetta-cli):

The private key of each created account is generated using the generate_key action:

The address is generated by calling the derive action (which calls the /construction/derive endpoint):

Lastly, the derived address and keypair are saved using the save_account action:

After CLI created account, I saw it request_fund and stuck there
I assume I need to pass my key somewhere so that request_fund can be processed . Because my account is the only one have funds

2020/10/21 13:55:12 processing workflow "request_funds" for job "1"
2020/10/21 13:55:12 looking for balance {"value":"10000000000000000","currency":{"symbol":"TOMO","decimals":18}} on account {"address":"0xefce3A8A86dbB6AD3FEf386324e74C31b0788e54"}
2020/10/21 13:55:12 processing workflow "transfer"
2020/10/21 13:55:12 looking for balance {"value":"10000000000000000","currency":{"symbol":"TOMO","decimals":18}}
2020/10/21 13:55:12 waiting for available jobs...

So, you have 2 options to continue from this point:

  1. Send funds to 0xefce3A8A86dbB6AD3FEf386324e74C31b0788e54 (the address created by the rosetta-cli)
  2. Restart the rosetta-cli and provide a list of “prefunded” accounts (with address + private key) so that you don’t need to fund the account during runtime:

If loading “prefunded” accounts is too burdensome, it is also possible to algorithmically faucet coins to a new account using the load_env action (to get an API token from the ENV) and the http_request action (unfortunately, I don’t yet have any examples of this):