Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending tokens from one address to another #26

Open
Tracked by #25
jbowen93 opened this issue Mar 7, 2022 · 1 comment
Open
Tracked by #25

Sending tokens from one address to another #26

jbowen93 opened this issue Mar 7, 2022 · 1 comment

Comments

@jbowen93
Copy link

jbowen93 commented Mar 7, 2022

Document the code flow when sending tokens from one address to another.

@jbowen93
Copy link
Author

jbowen93 commented Mar 7, 2022

We'll start by documenting how to send transactions from one address to another using the ephemeral cluster, then go step by step through the code this executes.

Ephemeral Cluster Setup

First start the ephemeral cluster from the jbowen93/evmos branch

git clone [email protected]:celestiaorg/ephemeral-cluster.git
git checkout jbowen93/evmos
./debug-start-cluster.sh

Watch the logs for the evmos container

docker logs evmos0 -f

These should be frozen at until you start a dlv remote debug session from Goland at localhost:40000. After you do this the Evmos container should start producing blocks.

Now set the ETH_RPC_URL

export ETH_RPC_URL=http://127.0.0.1:8545

Keys and Addresses

First we need to get the private key of the Cevmos validator using:

./val-priv-key.sh

Set this value to KEY1

export KEY1=<priv-key>

Derive the address

cast wallet address --private-key=$KEY1

Set this value to ADDR1

export ADDR1=<address>

We need a second to send the tokens to, we can get this with

./create-evm-key.sh

Get the value printed under external key and set it to KEY2

export KEY2=<external-key>

Derive the address

cast wallet address --private-key=$KEY2

Set this value to ADDR2

export ADDR2=<address>

Sending Tokens

Check the balance of the validator account

cast balance $ADDR1

It should be

99999000000000000000002500

Check the balance of the second account

cast balance $ADDR2

It should be

0

Now lets try sending some tokens from the validator account to the new account.

cast send --value 10 $ADDR2 --private-key=$KEY1

This command defaults to synchronous and so should hang until a new block is generated. You can see when this occurs by watching the evmos container logs

docker logs evmos0 -f

Once a new block is committed with our Tx included you should get a response like

blockHash            "0x14fb33cd77b43d9b7a13d27ed2bdf77ab58b7968a486b80e7f0bfbb312e17c59"
blockNumber          "0x21"
contractAddress      null
cumulativeGasUsed    "0x5208"
effectiveGasPrice    "0xb38ada6a"
gasUsed              "0x5208"
logs                 []
logsBloom            "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
root                 null
status               "0x1"
transactionHash      "0xd75b95e6020c431febfe4000bc00fc3fc87a0afce823f1fa202c060d4aa26399"
transactionIndex     "0x0"
type                 "0x2"

Check the balance of the second account

cast balance $ADDR2

It should be

10

Check the balance of the validator account

cast balance $ADDR1

It should be lower than it previously was, but the exact value will depend on how much gas it cost to send the Tx.

Debugging through the Code

Starting from the github.com/gakonst/foundry and github.com/gakonst/ethers-rs code

When running

cast send --value 10 $ADDR2 --private-key=$KEY1

The list of calls made from the client are

  1. eth_chainId
  2. eth_getTransactionCount
  3. eth_sendRawTransaction
  4. eth_getTransactionReceipt
  5. eth_getTransactionByHash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant