Skip to content

consensusnetworks/ssv-network

 
 

Repository files navigation

SSV Network Project

This repository contains a SSVRegistry and SSVNetwork smart contacts project.

Quick start

The first things you need to do are cloning this repository and installing its dependencies:

git clone [email protected]:bloxapp/ssv-network.git
cd ssv-network
npm install

Run locally HardHat TestNetwork node

Once installed, to run Hardhat's testing network:

npx hardhat node

For more details about it and how to use MainNet forking you can find here.

Compile contracts

Take a look at contracts/ folder, you should be able to find SSVNetwork.sol, SSVNetworkV2.sol as simple contract example. To compile it, simply run:

npx hardhat compile

CI/CD Workflow

Step 1: Test contracts

Take a look at test/ folder, you should be able to find tests related to specific actions. It comes with tests that use Waffle and Ethers.js. To run tests, run:

npx hardhat test

Step 2: Deploy new contracts

We use Proxy Upgrade pattern for smart contracts to have an ability to upgrade them later. To deploy the contract we will use a Hardhat script. Inside scripts/ you will find ssv-registry-deploy.ts and ssv-network-deploy.ts files. As general rule, you can target any network configured in the hardhat.config.ts

Deploy SSV Registry

npx hardhat run --network <your-network> scripts/ssv-registry-deploy.ts

Output of this action will be smart SSV Registry contract proxy address.

Deploy SSV Network

Before run the cli command, in .env need to add the following seetings:

SSVREGISTRY_ADDRESS=#SSV Registry contract address
SSVTOKEN_ADDRESS=#SSV Token contract address

After that:

npx hardhat run --network <your-network> scripts/ssv-network-deploy.ts

Output of this action will be smart SSV Network contract proxy address.

Step 3: Verify implementation contract on etherscan (each time after upgrade)

Open .openzeppelin/<network>.json file and find [impls.<hash>.address] value which is implementation smart contract address. We use Proxy Upgrade pattern for smart contracts to have an ability to upgrade them later. To deploy the contract we will use a Hardhat script. Inside scripts/ you will find deploy.ts file. Run this:

npx hardhat  verify --network <network> <implementation-address>

Step 4: Link proxy contract with implementation on etherscan (each time after upgrade)

Go to https://<network>.etherscan.io/address/<proxy-address> and click on Contract tab. On a right side click More Options dropbox and select Is this a proxy?. On a verification page enter proxy address inside field and click Verify button. As result you will see the message:

The proxy contract verification completed with the message:
The proxy\'s (<proxy-address) implementation contract is found at: <implementation-address>

To be sure that values are correct and click Save button. As result on etherscan proxy address page in Contract tab you will find two new buttons: Write as Proxy and Read as Proxy which will represent implementation smart contract functions interface and the actual state.

Step 5: Upgrade contract

Once we have tested our new implementation, for example contracts/SSVNetwork.sol we can prepare the upgrade. This will validate and deploy our new implementation contract.

Upgrade SSV Registry contract:

PROXY_ADDRESS=0x... npx hardhat run --network <network> scripts/ssv-registry-upgrade.ts

Upgrade SSV Network contract:

PROXY_ADDRESS=0x... npx hardhat run --network <network> scripts/ssv-network-upgrade.ts

dApp UI to interact with smart contract

https://eth95.dev/?network=1&address=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0

UI dApp direct link

User Guide

You can find detailed instructions on using this repository and many tips in its documentation. For a complete introduction to Hardhat, refer to this guide.

What’s Included?

Your environment will have everything you need to build a Dapp powered by Hardhat and React.

  • Hardhat: An Ethereum development task runner and testing network.
  • Mocha: A JavaScript test runner.
  • Chai: A JavaScript assertion library.
  • ethers.js: A JavaScript library for interacting with Ethereum.
  • Waffle: To have Ethereum-specific Chai assertions/mathers.

Security Audit [OLD Version]

Full audit report CoinFabrik Report

Troubleshooting

  • Invalid nonce errors: if you are seeing this error on the npx hardhat node console, try resetting your Metamask account. This will reset the account's transaction history and also the nonce. Open Metamask, click on your account followed by Settings > Advanced > Reset Account.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 69.3%
  • Solidity 30.5%
  • Shell 0.2%