Skip to content

dotOneSmartChain/dotonebridge-contracts

Repository files navigation

Dotone Contracts: Oilcoin, BSC Testnet & Ethereum Sepolia

This project is a cleaned Dotone Solidity contracts workspace configured to deploy to:

  • Oilcoin (DT1) — id: oil (configured under testnets)
  • BSC Testnet — id: bnb-testnet
  • Ethereum Sepolia — id: ethereum-sepolia

All other networks and tokens have been removed from the presets.

Initialization (first run)

  1. Install dependencies
yarn
  1. Select a chain config (writes contracts/utils/DotoneConfig.sol)
# Oilcoin testnet
npx hardhat chain --testnet oil
# or BSC testnet
npx hardhat chain --testnet bnb-testnet
  1. Compile contracts
yarn compile
  1. Generate local ABIs and TS contract types for packages (no npm installs)
node scripts/copy-abis.js
node scripts/copy-types.js
  1. Build monorepo packages (base, adaptors, rpc, client, sdk, presets, clients)
yarn build:packages
  1. Set your deployer key
echo "PRIVATE_KEY=0xYOUR_PRIVATE_KEY" > .env

Quick start: Step‑by‑step deploy to a chain

  1. Use Node 22 and Yarn classic
nvm use 22 || (nvm install 22 && nvm use 22)
corepack enable && corepack prepare yarn@1.22.22 --activate
node -v && yarn -v
  1. Install and build packages
yarn
yarn build:packages
  1. Set your deployer key
echo "PRIVATE_KEY=0xYOUR_PRIVATE_KEY" > .env
  1. Pick a network id
  • Oilcoin testnet: oil
  • BSC testnet: bnb-testnet
  • Ethereum Sepolia: ethereum-sepolia
  1. Deploy (upgradable)
# Oilcoin testnet
yarn compile
yarn deploy:oil

# OR BSC testnet
yarn compile
yarn deploy:bsc-testnet

# OR Ethereum Sepolia
yarn compile
yarn deploy:ethereum-sepolia

Equivalent generic form:

npx hardhat deploy --testnet oil --upgradable true
# or
npx hardhat deploy --testnet bnb-testnet --upgradable true
# or
npx hardhat deploy --testnet ethereum-sepolia --upgradable true
  1. Verify outputs
  • Console will print deployed proxy/implementation (when upgradable) and Dotone address.
  • File packages/base/networks/testnets.json will be updated:
    • The dotoneAddress field under your network will be filled.
    • Any test tokens deployed during the run will have their addr filled.
  1. Sanity checks
# Confirm the network entry contains a non-empty dotoneAddress
grep -n '"id": "oil"' -n packages/base/networks/testnets.json -n && \
  sed -n '1,60p' packages/base/networks/testnets.json | sed -n '1,40p'
  • Ensure the deployer wallet had gas on the target network (DT1 or tBNB).
  • If you re‑deploy, hardhat deploy will re‑switch config, recompile, and redeploy.
  1. Next steps (optional)
  • Add/remove supported tokens by editing the tokens list of the target network in packages/base/networks/testnets.json and re‑deploy.
  • For LP operations (deposit/withdraw/authorize), see scripts/lib/pool.js. It is sample code; wire it as needed for your use case.

End‑to‑end deploy checklist (what we did)

  1. Build workspaces
nvm use 22
yarn && yarn build:packages
  1. Fund deployer wallet with native gas on both testnets (DT1 on Oilcoin, tBNB on BSC Testnet)

  2. Set deployer key and compile

echo "PRIVATE_KEY=0xYOUR_PRIVATE_KEY" > .env
yarn compile
  1. Deploy on testnets
yarn deploy:oil
yarn deploy:bsc-testnet
yarn deploy:ethereum-sepolia
  • dotoneAddress in packages/base/networks/testnets.json is filled automatically. No manual edit needed.
  1. (Optional) Generate ABIs/types for consumers
node scripts/copy-abis.js
node scripts/copy-types.js
  1. (Optional) Env toggles
  • PREMIUM_MANAGER: address to set as premium manager (defaults to deployer).
  • DEPOSIT_ON_DEPLOY: string amount (e.g. "1000") to auto‑deposit LP balances for listed tokens on testnets.

Optional: Run a relayer service

For running a relayer service to execute swaps, see the dotone-bridge-relayer project documentation. The relayer listens for swap events and executes corresponding transactions on destination chains.

Requirements

  • Node.js 22
  • Yarn 1.x

Install

yarn
yarn build:packages

Configure your deployer

Set your private key in one of these ways (preferred first):

  1. Create .env in the project root:
PRIVATE_KEY=0xYOUR_PRIVATE_KEY
  1. Or export in your shell:
export PRIVATE_KEY=0xYOUR_PRIVATE_KEY
  1. Or inline per command:
PRIVATE_KEY=0xYOUR_PRIVATE_KEY npx hardhat deploy --testnet oil --upgradable true

Note: PRIVATE_KEY is required for all deployment scripts. Scripts will fail with an error if it's not set. Always set your own key in production.

Networks

Oilcoin (DT1)

  • id: oil
  • chainId: 75245483421285 (0x446f744f6e65)
  • rpc: https://rpc-testnet.oilcoin.online/
  • explorer: https://explorer.oilcoin.online/
  • native currency: DT1 (18)
  • tokens (presets): DT1 native only

Deploy:

yarn compile
yarn deploy:oil
# equivalent: npx hardhat deploy --testnet oil --upgradable true

BSC Testnet

  • id: bnb-testnet
  • chainId: 97 (0x61)
  • rpc: https://bsc-testnet-rpc.publicnode.com
  • explorer: https://testnet.bscscan.com
  • native currency: tBNB (18)
  • tokens (presets): tBNB native, LINK 0x84b9B910527Ad5C03A9Ca831909E21e236EA7b06 (18)

Deploy:

yarn compile
yarn deploy:bsc-testnet
# equivalent: npx hardhat deploy --testnet bnb-testnet --upgradable true

Ethereum Sepolia

  • id: ethereum-sepolia
  • chainId: 11155111 (0xaa36a7)
  • rpc: https://ethereum-sepolia-rpc.publicnode.com
  • explorer: https://sepolia.etherscan.io/
  • native currency: ETH (18)
  • tokens (presets): None (tokens can be added after deployment)

Deploy:

yarn compile
yarn deploy:ethereum-sepolia
# equivalent: npx hardhat deploy --testnet ethereum-sepolia --upgradable true

Build and compile

The build script ensures chain config is applied:

yarn build   # runs: hardhat chain --testnet oil && hardhat clean && yarn compile
yarn compile

The Hardhat deploy task also switches chain config automatically before compile and deploy.

Generate ABIs and contract types (for @dotone/base)

After compiling, populate real ABIs and TypeScript contract types into packages/base/abis:

Option A (automatic): runs on full build

yarn build   # triggers postbuild → scripts/copy-abis.js && scripts/copy-types.js

Option B (manual): run copy scripts explicitly

# Ensure artifacts and typechain-types exist
yarn compile
# Then copy ABIs and types into packages/base/abis
node scripts/copy-abis.js
node scripts/copy-types.js

Results:

  • packages/base/abis/DotoneAbi.json (from artifacts/contracts/Dotone.sol/Dotone.json)
  • packages/base/abis/ERC20Abi.json (from artifacts/contracts/test/MockToken.sol/MockToken.json)
  • packages/base/abis/DotoneContract.d.ts, ERC20Contract.d.ts, ContractTypes.d.ts (from typechain-types)

What deployment does

  • Copies chain-specific DotoneConfig.sol into contracts/utils/
  • Compiles contracts
  • Deploys upgradable Dotone (unless --upgradable false)
  • Registers preset tokens on the deployed Dotone contract
  • Writes the deployed Dotone address back to the network preset file

Relevant files:

  • packages/base/networks/testnets.json
  • packages/base/networks/mainnets.json (contains only Ethereum and BNB)
  • scripts/deploy.js
  • contracts/utils/DotoneConfig.sol

Troubleshooting

  • Ensure your wallet has gas on the target network (DT1 on Oilcoin, tBNB on BSC Testnet).
  • If PRIVATE_KEY is not picked up, verify .env is in the project root and re-run the command from that directory.
  • If deployment succeeds but tokens are missing, confirm token entries in the corresponding network preset file.

FAQ

  • What is dotoneAddress in the network JSONs?
    • It is the deployed Dotone contract (proxy if upgradable) on that chain. You do not set it manually before deploy. The deploy script writes it after deployment.
  • Do I need to pre-fill token addresses on testnets?
    • No. If a token in packages/base/networks/testnets.json has an empty addr, the testnet deploy script will auto-deploy a MockToken and update the file with the new address.
  • Where is the relayer documentation?
    • See the dotone-bridge-relayer project for relayer setup and configuration.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages