Skip to content

Commit

Permalink
Add links
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Eckardt <martin.eckardt@avalabs.org>
  • Loading branch information
martineckardt authored Apr 25, 2024
1 parent b770549 commit 1b13452
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/0-send-receive/_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Instructions - Send & Receive

The following code example will show you how to send, receive and verify the receival of messages using teleporter and foundry.
The following code example will show you how to send, receive and verify the receival of messages using teleporter and foundry. It includes instructions for the [local network](#local-network) and [fuji testnet](#fuji-testnet).

## Issuing Transactions with Foundry

### Local Network
## Local Network

For convenience the private key `56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027` of the default airdrop address is stored in the environment variable `$PK`. Furthermore, the RPC-url for the C-Chain of your local network is set in the `foundry.toml` file.

#### Setting the Blockchain ID in the Contracts
### Setting the Blockchain ID in the Contracts

Make sure to replace the blockchainID in the sender contract `src/0-send-receive/senderOnCChain.sol` with the ID of your Subnet's blockchain.

Expand All @@ -34,7 +32,7 @@ teleporterMessenger.sendCrossChainMessage(
);
```

#### Deploying the Contracts
### Deploying the Contracts

After adapting the contracts you can deploy them with `forge create`:

Expand All @@ -48,23 +46,23 @@ forge create --rpc-url mysubnet --private-key $PK src/0-send-receive/receiverOnS

```

#### Sending a Message
### Sending a Message

You can find `<sender_contract_address>` in the output of the first and the `<receiver_contract_address>` of the second `forge create` command in the line saying `Deployed to:`.

```bash
cast send --rpc-url local-c --private-key $PK <sender_contract_address> "sendMessage(address,string)" <receiver_contract_address> "Hello"
```

#### Verifying Message Receipt
### Verifying Message Receipt

```bash
cast call --rpc-url mysubnet <receiver_contract_address> "lastMessage()(string)"
```

### Fuji Testnet
## Fuji Testnet

#### Creating a Wallet
### Creating a Wallet

For deploying on testnet, we cannot use the airdrop wallet, since the private key is commonly known. To create a new wallet that is stored in a keystore, issue the following command. It will prompt you to secure the private key with a password.

Expand All @@ -80,11 +78,11 @@ You can use the wallet stored in the keystore by adding the `--keystore` flag in
cast wallet address --keystore $KEYSTORE
```

#### Funding your Wallet with Fuji Tokens
### Funding your Wallet with Fuji Tokens

Head to the [Avalanche Testnet Faucet](https://core.app/tools/testnet-faucet/?subnet=c&token=c) and fund your keystore address with Fuji AVAX and Dispatch tokens. Use the coupon code `avalanche-academy`.

#### Setting the Blockchain ID in the Contracts on Fuji
### Setting the Blockchain ID in the Contracts on Fuji

Make sure to adapt the destinationBlockchainID of your sending contracts to use the blockchain IDs of the Fuji network:

Expand All @@ -93,7 +91,7 @@ Make sure to adapt the destinationBlockchainID of your sending contracts to use
| Fuji C-Chain | 0x7fc93d85c6d62c5b2ac0b519c87010ea5294012d1e407030d6acd0021cac10d5 |
| Dispatch | 0x9f3be606497285d0ffbb5ac9ba24aa60346a9b1812479ed66cb329f394a4b1c7 |

#### Deploying the Contracts
### Deploying the Contracts

After adapting the contracts you can deploy them using your keystore wallet:

Expand All @@ -106,14 +104,14 @@ forge create --rpc-url dispatch --keystore $KEYSTORE src/0-send-receive/receiver
```

#### Sending a Message
### Sending a Message

```bash
cast send --rpc-url fuji-c --keystore $KEYSTORE <sender_contract_address> "sendMessage(address,string)" <receiver_contract_address> "Hello"
```

#### Verifying Message Receipt
### Verifying Message Receipt

```bash
cast call --rpc-url dispatch <receiver_contract_address> "lastMessage()(string)"
```
```

0 comments on commit 1b13452

Please sign in to comment.