97 lines
4 KiB
Markdown
97 lines
4 KiB
Markdown
# Your first contract on the devnet, in five minutes
|
|
|
|
With Foundry. Tested end to end on a build box; the pass line and the exact output are at the end. Hardhat, ethers and viem work the same way: chain id 4465 and the RPC below.
|
|
|
|
## 0. What you need
|
|
|
|
- Foundry: `curl -L https://foundry.paradigm.xyz | bash && foundryup`. About a minute.
|
|
- The RPC. The devnet's public endpoint is `https://rpc.devnet.igneum.network`. A node you run yourself serves `http://127.0.0.1:26790`.
|
|
- Nothing else. No account, no sign-up.
|
|
|
|
```
|
|
export RPC=https://rpc.devnet.igneum.network
|
|
cast chain-id --rpc-url $RPC # 4465
|
|
```
|
|
|
|
## 1. A key, for the devnet only
|
|
|
|
```
|
|
cast wallet new
|
|
```
|
|
|
|
It prints an address and a private key. Keep the key for this walkthrough and nothing else: devnet coins have no value and the chain resets without notice.
|
|
|
|
```
|
|
export PK=0x... # the private key cast printed
|
|
export ME=$(cast wallet address $PK)
|
|
```
|
|
|
|
## 2. Coins from the faucet
|
|
|
|
Paste `$ME` into [igneum.network/faucet](https://igneum.network/faucet). It sends 10 IGN and shows the transaction hash. Once per address per day.
|
|
|
|
```
|
|
cast balance $ME --rpc-url $RPC --ether # 10.000000000000000000
|
|
```
|
|
|
|
## 3. Deploy
|
|
|
|
Foundry's template is a counter. Initialise it and deploy it as it is.
|
|
|
|
```
|
|
forge init counter && cd counter
|
|
forge create src/Counter.sol:Counter --rpc-url $RPC --private-key $PK --broadcast
|
|
```
|
|
|
|
Expected:
|
|
|
|
```
|
|
Deployer: 0x...
|
|
Deployed to: 0x...
|
|
Transaction hash: 0x...
|
|
```
|
|
|
|
```
|
|
export C=0x... # the Deployed to address
|
|
```
|
|
|
|
## 4. Call it
|
|
|
|
```
|
|
cast send $C "increment()" --rpc-url $RPC --private-key $PK
|
|
cast call $C "number()(uint256)" --rpc-url $RPC # 1
|
|
cast send $C "setNumber(uint256)" 41 --rpc-url $RPC --private-key $PK
|
|
cast call $C "number()(uint256)" --rpc-url $RPC # 41
|
|
```
|
|
|
|
`cast send` waits for the receipt. A block takes about a second.
|
|
|
|
## 5. See it
|
|
|
|
Paste the transaction hash into [igneum.network/explorer](https://igneum.network/explorer). The receipt is also one call away:
|
|
|
|
```
|
|
cast receipt 0xTXHASH --rpc-url $RPC
|
|
```
|
|
|
|
## What is different under the hood
|
|
|
|
- Gas has two dimensions, execution and proving. The node folds the second into the price it quotes, so `forge` and `cast` estimate and pay as on Ethereum. `igneum_estimateGas` shows both numbers and whether a call exceeds the proving limit.
|
|
- Your transaction is in a block within about a second, proven tens of seconds later, and locked by miner signatures in about two minutes. `igneum_getTransactionStatus` reports each stage.
|
|
- A transaction signed for another chain id is refused. EIP-155, EIP-1559 and legacy envelopes are accepted.
|
|
|
|
## The test record
|
|
|
|
Run on a build box against its own devnet node (the box that also fronts the public RPC and runs the faucet), with Foundry 1.8.5 and a fresh key, through `docs/build/first-contract-test.sh`. The pass line is appended below by the run (the lines below are historical records of earlier devnets, chain ids 4463 and 4464; the Igneum 2.0 devnet answers 4465).
|
|
|
|
```
|
|
PASS 10:17:23Z: devnet chain id 4463, faucet drip 0x8620e9d894484e824e4ac33002946a00e2f75823ea6db0da0ad29f1af142e8f2, deployed Counter at 0x6345265C6Db0b3713eb6645d795d0B52FE0a4201 (tx 0xcf77b4822d51f3c60ecdf6d7dbbe67524d42071f06c76e1cf9b0511d64783574), increment then setNumber(41) read back 41, receipt status 1 (success), block 27055, 24 s end to end, Foundry 1.8.5
|
|
```
|
|
|
|
Through the public endpoints, `https://rpc.devnet.igneum.network` and `https://faucet.igneum.network`, from the box: the first faucet drip and the first reader-path deploy on the devnet.
|
|
|
|
Historical record (an earlier devnet, chain id 4464 after its class v5 floor; the Igneum 2.0 devnet answers 4465), from a second box:
|
|
|
|
```
|
|
PASS 12:38:39Z: devnet chain id 4464, faucet drip 0xa54fdb7e964dab095aaccaab36ea548fc3fa8727acb809b593c2d4d1359c233f, deployed Counter at 0x7de503a4F39feEBCE8c4ABbAcC04282EE75120Fe (tx 0x6ccdbb4f6393fcf09e58ba2f4de1af98c547eeab6f02d93eacfebae883200dc6), increment then setNumber(41) read back 41, receipt status 1 (success), block 29878, 12 s end to end, Foundry 1.8.5
|
|
```
|