Skip to content
Testnet

Deploy with Foundry and Hardhat ​

The RPC is https://rpc.utn.network. Chain id is 20261021. Transactions are legacy with gas price 0. The signing account must be an allowlisted company member.

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 viem

The installed name is @utn/umbro.

js
import { abi, standards } from "@utn/umbro";

console.log(Object.keys(standards));

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 {IOrgAccount} from "./IOrgAccount.sol";

IOrgAccount is the organization account: owner(), isAdmin(address), and hasRole(bytes32,address). Organizations are registered by approved companies. See Create an organization.

Read a contract ​

This calls name() on the organizations registry.

js
import { createPublicClient, http } from "viem";

const address = "0xD8e6dCEd3a78B510be5fa351E6faA07EE6D3C424";

const client = createPublicClient({
  transport: http("https://rpc.utn.network"),
});

const name = await client.readContract({
  address,
  abi: [{ type: "function", name: "name", stateMutability: "pure", inputs: [], outputs: [{ type: "string" }] }],
  functionName: "name",
});

console.log(name);
bash
node call.mjs

encodeFunctionData builds the data field of a transaction. It does not send anything.

js
import { encodeFunctionData } from "viem";

const data = encodeFunctionData({
  abi: [{ type: "function", name: "name", stateMutability: "pure", inputs: [], outputs: [{ type: "string" }] }],
  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. Match those settings or the deployed code will not verify. An organization is registered with register on the registry, of your company. A Foundry script deploys your own contract and passes the organization account into the constructor.

solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {Script} from "forge-std/Script.sol";
import {UseYourOrg} from "./UseYourOrg.sol";
import {IOrganizations} from "./IOrganizations.sol";
import {IOrgAccount} from "./IOrgAccount.sol";

contract DeployUseYourOrg is Script {
    function run() external {
        vm.startBroadcast();
        new UseYourOrg(
            IOrganizations(0xD8e6dCEd3a78B510be5fa351E6faA07EE6D3C424),
            IOrgAccount(vm.envAddress("ORG_ACCOUNT"))
        );
        vm.stopBroadcast();
    }
}

ORG_ACCOUNT is the organization account of your company. 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: 20261021,
    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 utn

Pass the organization account the way the Foundry script does. Creating that account is Create an organization.

Do not commit PRIVATE_KEY.

T-RAIN · chain 20261021