-
Notifications
You must be signed in to change notification settings - Fork 0
How to deploy a contract to Sonieum Minato using Foundry
Stardust⨠edited this page Aug 26, 2025
·
4 revisions
Before reading this wiki, please check the following wikis.
If you have completed the steps in them, you already have a fully synchronized Minato node and You have Minato ETH.
- If the result returns false, synchronization is complete.
admin@Soneians:~/soneium-minato-node$ curl -X POST http://127.0.0.1:8545 \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}'
{"jsonrpc":"2.0","id":1,"result":false}
- Confirm via your own RPC that your wallet holds 0.1 ETH.
admin@Soneians:~/soneium-minato-node$ curl -X POST http://127.0.0.1:8545 \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["WALLET_ADDRESS","latest"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x16345785d8a0000"}
admin@Soneians:~/soneium-minato-node$ python3 -c 'print(int("0x16345785d8a0000",16)/1e18)'
0.1
admin@Soneians:~$ curl -s -X POST http://127.0.0.1:8545 \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' | jq -r '.result'
0x79a
admin@Soneians:~$ printf "%d\n" 0x79a
1946
admin@Soneians:~$ curl -L https://foundry.paradigm.xyz | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 167 100 167 0 0 1588 0 --:--:-- --:--:-- --:--:-- 1575
100 2196 100 2196 0 0 6489 0 --:--:-- --:--:-- --:--:-- 6489
Installing foundryup...
Detected your preferred shell is bash and added foundryup to PATH.
Run 'source /home/admin/.bashrc' or start a new terminal session to use foundryup.
Then, simply run 'foundryup' to install Foundry.
admin@Soneians:~/foundry$ exec $SHELL -l
admin@Soneians:~/foundry$ foundryup
.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx
βββ βββ β¦ β¦ βββ ββ¦β β¦ββ β¦ β¦ Portable and modular toolkit
β β£ β β β β βββ ββ β β¦β ββ¦β for Ethereum Application Development
β βββ βββ βββ ββ©β β©ββ β© written in Rust.
.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx
Repo : https://github.com/foundry-rs/foundry
Book : https://book.getfoundry.sh/
Chat : https://t.me/foundry_rs/
Support : https://t.me/foundry_support/
Contribute : https://github.com/foundry-rs/foundry/blob/master/CONTRIBUTING.md
.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx
admin@Soneians:~$ forge init hello-foundry
Initializing /home/admin/hello-foundry...
Installing forge-std in /home/admin/hello-foundry/lib/forge-std (url: Some("https://github.com/foundry-rs/forge-std"), tag: None)
Cloning into '/home/admin/hello-foundry/lib/forge-std'...
remote: Enumerating objects: 2201, done.
remote: Counting objects: 100% (1043/1043), done.
remote: Compressing objects: 100% (147/147), done.
remote: Total 2201 (delta 964), reused 899 (delta 896), pack-reused 1158 (from 2)
Receiving objects: 100% (2201/2201), 723.85 KiB | 20.11 MiB/s, done.
Resolving deltas: 100% (1479/1479), done.
Installed forge-std tag=v1.10.0@8bbcf6e3f8f62f419e5429a0bd89331c85c37824
Initialized forge project
admin@Soneians:~$ cd hello-foundry
admin@Soneians:~/hello-foundry$ tree
.
βββ README.md
βββ foundry.lock
βββ foundry.toml
βββ lib
β βββ forge-std
β βββ CONTRIBUTING.md
β βββ LICENSE-APACHE
β βββ LICENSE-MIT
β βββ README.md
β βββ foundry.toml
β βββ package.json
β βββ scripts
β β βββ vm.py
β βββ src
β β βββ Base.sol
β β βββ Script.sol
β β βββ StdAssertions.sol
β β βββ StdChains.sol
β β βββ StdCheats.sol
β β βββ StdConstants.sol
β β βββ StdError.sol
β β βββ StdInvariant.sol
β β βββ StdJson.sol
β β βββ StdMath.sol
β β βββ StdStorage.sol
β β βββ StdStyle.sol
β β βββ StdToml.sol
β β βββ StdUtils.sol
β β βββ Test.sol
β β βββ Vm.sol
β β βββ console.sol
β β βββ console2.sol
β β βββ interfaces
β β β βββ IERC1155.sol
β β β βββ IERC165.sol
β β β βββ IERC20.sol
β β β βββ IERC4626.sol
β β β βββ IERC6909.sol
β β β βββ IERC721.sol
β β β βββ IERC7540.sol
β β β βββ IERC7575.sol
β β β βββ IMulticall3.sol
β β βββ safeconsole.sol
β βββ test
β βββ CommonBase.t.sol
β βββ StdAssertions.t.sol
β βββ StdChains.t.sol
β βββ StdCheats.t.sol
β βββ StdConstants.t.sol
β βββ StdError.t.sol
β βββ StdJson.t.sol
β βββ StdMath.t.sol
β βββ StdStorage.t.sol
β βββ StdStyle.t.sol
β βββ StdToml.t.sol
β βββ StdUtils.t.sol
β βββ Vm.t.sol
β βββ compilation
β β βββ CompilationScript.sol
β β βββ CompilationScriptBase.sol
β β βββ CompilationTest.sol
β β βββ CompilationTestBase.sol
β βββ fixtures
β βββ broadcast.log.json
β βββ test.json
β βββ test.toml
βββ script
β βββ Counter.s.sol
βββ src
β βββ Counter.sol
βββ test
βββ Counter.t.sol
12 directories, 61 files
admin@Soneians:~/hello-foundry$ cat src/HelloWorld.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract HelloWorld {
string private greeting;
constructor(string memory _greeting) {
greeting = _greeting;
}
function greet() external view returns (string memory) {
return greeting;
}
function setGreeting(string calldata _greeting) external {
greeting = _greeting;
}
}
admin@Soneians:~/hello-foundry$ cat script/HelloWorld.s.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Script} from "forge-std/Script.sol";
import {console2} from "forge-std/console2.sol";
import {HelloWorld} from "../src/HelloWorld.sol";
contract HelloWorldScript is Script {
function run() external {
uint256 deployerKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerKey);
HelloWorld hw = new HelloWorld("Hello, Soneium!");
vm.stopBroadcast();
console2.log("HelloWorld deployed at:", address(hw));
}
}
admin@Soneians:~/hello-foundry$ cat foundry.toml
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
chain_id = 1946
- Create
.envfile
admin@Soneians:~/hello-foundry$ cat .env
PRIVATE_KEY=0x[secret key]
RPC_URL=http://127.0.0.1:8545
- Load
.envfile
admin@Soneians:~/hello-foundry$ set -a; source .env; set +a
admin@Soneians:~/hello-foundry$ forge build
[β ] Compiling...
[β ] Compiling 1 files with Solc 0.8.30
[β ] Solc 0.8.30 finished in 401.46ms
Compiler run successful!
admin@Soneians:~/hello-foundry$ forge script script/HelloWorld.s.sol:HelloWorldScript \
--rpc-url $RPC_URL \
--broadcast \
--private-key $PRIVATE_KEY
[β ] Compiling...
No files changed, compilation skipped
Script ran successfully.
== Logs ==
HelloWorld deployed at: 0x4B3a4b61304B242D022362a5C80d7fBc7ab25459
## Setting up 1 EVM.
==========================
Chain 1946
Estimated gas price: 0.000000505 gwei
Estimated total gas used for script: 526575
Estimated amount required: 0.000000000265920375 ETH
==========================
##### soneium-minato-testnet
β
[Success] Hash: 0x870e4587b3bdf97638d01b58f25ad4da5160c13e3fdcec87d2a3db5bc192910a
Contract Address: 0x4B3a4b61304B242D022362a5C80d7fBc7ab25459
Block: 16427595
Paid: 0.000000000102479674 ETH (405058 gas * 0.000000253 gwei)
β
Sequence #1 on soneium-minato-testnet | Total Paid: 0.000000000102479674 ETH (405058 gas * avg 0.000000253 gwei)
==========================
ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
Transactions saved to: /home/admin/hello-foundry/broadcast/HelloWorld.s.sol/1946/run-latest.json
Sensitive values saved to: /home/admin/hello-foundry/cache/HelloWorld.s.sol/1946/run-latest.json
- Execute contract
admin@Soneians:~/hello-foundry$ ADDR=0x4B3a4b61304B242D022362a5C80d7fBc7ab25459
admin@Soneians:~/hello-foundry$ cast call $ADDR "greet()(string)" --rpc-url $RPC_URL
"Hello, Soneium!"
- Change contract state
admin@Soneians:~/hello-foundry$ cast send $ADDR "setGreeting(string)" "GM, Soneians!" --rpc-url $RPC_URL --private-key $PRIVATE_KEY
blockHash 0x45b43535375a1ed2572f6313effd39ca10fedbc12af6ac36b59f37f715ee5dcc
blockNumber 16428738
contractAddress
cumulativeGasUsed 73843
effectiveGasPrice 100000252
from 0x53869B88306EB505f0fC66DaE482D42033F85253
gasUsed 27687
logs []
logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
root
status 1 (success)
transactionHash 0xad638d5587682bf676c485512d93df1d8163be0b28c392bbdc8d4b7a7bfb2d61
transactionIndex 1
type 2
blobGasPrice
blobGasUsed
to 0x4B3a4b61304B242D022362a5C80d7fBc7ab25459
l1BaseFeeScalar 9736
l1BlobBaseFee 534
l1BlobBaseFeeScalar 1540079
l1Fee 16094870726
l1GasPrice 1033200781
l1GasUsed 1600
admin@Soneians:~/hello-foundry$ cast call $ADDR "greet()(string)" --rpc-url $RPC_URL
"GM, Soneians!"