Skip to content

Commit f98408b

Browse files
authoredMar 19, 2025
Merge pull request #256 from sei-protocol/feature/foundry-tweaks
Small Changes to EVM Foundry Tutorial
2 parents 137385a + 3e7346b commit f98408b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed
 

‎content/evm/evm-foundry.mdx

+13-7
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ $ forge test
7878
If tests pass, deploy the contract to the Sei chain with the following command:
7979

8080
```bash copy
81-
$ forge create --rpc-url $SEI_NODE_URI --mnemonic $MNEMONIC src/Counter.sol:Counter
81+
$ forge create --rpc-url $SEI_NODE_URI --mnemonic $MNEMONIC src/Counter.sol:Counter --broadcast
8282
```
8383

8484
Where `$SEI_NODE_URI` is the URI of the Sei node and `$MNEMONIC` is the mnemonic of the account that will deploy the contract. If you run local Sei node, the address will be `http://localhost:8545` , otherwise you could grab a `evm_rpc` url from the [registry](https://github.com/sei-protocol/chain-registry/blob/main/chains.json). If deployment is successful, you will get the EVM contract address in the output.
@@ -109,15 +109,21 @@ If command is successful, you will get the transaction hash and other info back.
109109

110110
Now let's call the `getCount` function again and this case it should return `1`.
111111

112-
## Calling contract from JS client
112+
```bash copy
113+
$ cast call $0X_CONTRACT_ADDRESS "getCount()(uint256)" --rpc-url $SEI_NODE_URI
114+
```
115+
116+
> Foundry generates the ABI for the contract in the `out` folder. You can use this ABI to interact with the contract from other tools like `ethers.js` or `web3.js`.
117+
118+
## Calling contract using ethers.js
113119

114-
To call contract from frontend, you could use `ethers` like:
120+
To call or query the contract from a frontend or a NodeJS script, you could use `ethers.js` like:
115121

116122
```tsx copy
117-
import {ethers} from "ethers";
123+
import { ethers } from 'ethers';
118124

119-
const privateKey = <Your Private Key>;
120-
const evmRpcEndpoint = <Your Evm Rpc Endpoint>
125+
const privateKey = YOUR_PRIVATE_KEY;
126+
const evmRpcEndpoint = YOUR_EVM_RPC_ENDPOINT;
121127
const provider = new ethers.JsonRpcProvider(evmRpcEndpoint);
122128
const signer = new ethers.Wallet(privateKey, provider);
123129

@@ -162,7 +168,7 @@ const abi = [
162168
];
163169

164170
// Define the address of the deployed contract
165-
const contractAddress = 0X_CONTRACT_ADDRESS;
171+
const contractAddress = `0X_CONTRACT_ADDRESS`;
166172

167173
// Create a new instance of the ethers.js Contract object
168174
const contract = new ethers.Contract(contractAddress, abi, signer);

0 commit comments

Comments
 (0)