- No matches
Deploy with Foundry and Hardhat
The RPC is https://rpc.utn.network. Chain id is 20261003. Transactions are legacy, with a gas price of at least 476 gwei (476000000000 wei). The account that signs needs T-RAIN.
Install the library
@utn/umbro contains the Solidity sources and the ABIs. It is not on the public npm registry yet, so npm install @utn/umbro returns a 404. Install from a clone:
bash
git clone --depth 1 https://github.com/AlexandruMares/UTN.git
mkdir utn-app
cd utn-app
npm init -y
npm install ../UTN/packages/umbro viemThe installed name is @utn/umbro.
js
import { abi, standards } from "@utn/umbro";
console.log(standards["UMBRO-ORG-26"].id);Publishing the package later does not deploy a contract. An address comes from a deploy.
A Foundry remapping, from the package README:
toml
remappings = ["@utn/umbro/=../UTN/packages/umbro/src/"]solidity
import {UmbroOrg26} from "@utn/umbro/org/UmbroOrg26.sol";Read a contract
ORG is an address you deployed. This calls name() and standard().
js
import { createPublicClient, http } from "viem";
import { abi } from "@utn/umbro";
const address = process.env.ORG;
if (!address) throw new Error("Set ORG to your contract address.");
const client = createPublicClient({
transport: http("https://rpc.utn.network"),
});
const name = await client.readContract({
address,
abi: abi.UmbroOrg26,
functionName: "name",
});
const standard = await client.readContract({
address,
abi: abi.UmbroOrg26,
functionName: "standard",
});
console.log(name);
console.log(standard);bash
ORG=0xYOUR_ORG_ADDRESS node call.mjsencodeFunctionData builds the data field of a transaction. It does not send anything.
js
import { encodeFunctionData } from "viem";
import { abi } from "@utn/umbro";
const data = encodeFunctionData({
abi: abi.UmbroOrg26,
functionName: "name",
args: [],
});Sending that data from a page is Connect a site.
Foundry
packages/umbro/foundry.toml compiles with solc 0.8.28, the optimizer on, and 200 runs. UmbroOrg26 is restricted to via IR so the bytecode stays under the 24 KB limit. Match those settings or the deployed code will not verify.
solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
import {Script} from "forge-std/Script.sol";
import {UmbroOrg26} from "@utn/umbro/org/UmbroOrg26.sol";
contract DeployOrg is Script {
function run() external {
address admin = vm.envAddress("ADMIN");
vm.startBroadcast();
new UmbroOrg26(admin, keccak256("my-org"), admin, "Northwind");
vm.stopBroadcast();
}
}ADMIN is the address that will be operator and firstAdmin. Install forge-std the way the package README does (forge install foundry-rs/forge-std --no-git from packages/umbro).
Broadcast with the same gas price the node enforces. deploy/oracle/health/tx-latency-test.sh passes --legacy --gas-price 476000000000 to cast. Use that gas price on the script broadcast as well. The script prints the new address.
Hardhat
network/template/hardhat.config.js is the repo's Hardhat network block. It reads the chain id and the minimum gas price from network/besu/config/testnet.json. Point url at the public RPC:
js
networks: {
utn: {
url: process.env.UTN_RPC || "https://rpc.utn.network",
chainId: 20261003,
gasPrice: 476000000000,
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
},
},
solidity: {
version: "0.8.28",
settings: { optimizer: { enabled: true, runs: 200 }, evmVersion: "prague" },
},The template's contracts/X.sol is an older example and is not the organization contract. Put the contract you want to deploy in contracts/, then:
bash
export UTN_RPC=https://rpc.utn.network
export PRIVATE_KEY=0xYOUR_KEY
npx hardhat run scripts/deploy.js --network utnFor UmbroOrg26, turn via IR on in the Solidity settings, as in Foundry. The constructor arguments are on Create an organization.
Do not commit PRIVATE_KEY.