Skip to content

Commit

Permalink
Exact setup from which mainnet beta deployment was done
Browse files Browse the repository at this point in the history
  • Loading branch information
chompomonim committed Oct 21, 2021
1 parent 5af63d1 commit c3043ea
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 25 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ Implementation addresses:
- Channel implementation address (Görli): `0x1aDF7Ef34b9d48DCc8EBC47D989bfdE55933B6ea`
- Channel implementation address (Mumbai): `0xf8982Ba93D3d9182D095B892DE2A7963eF9807ee`


## MainNet beta deployment

Registry smart contract:
- Polygon [0x87F0F4b7e0FAb14A565C87BAbbA6c40c92281b51](https://polygonscan.com/address/0x87F0F4b7e0FAb14A565C87BAbbA6c40c92281b51)
- Ethereum [0x87F0F4b7e0FAb14A565C87BAbbA6c40c92281b51](https://etherscan.io/address/0x87f0f4b7e0fab14a565c87babba6c40c92281b51)

Hermes smart contract
- Polygon [0xa62a2A75949d25e17C6F08a7818e7bE97c18a8d2](https://polygonscan.com/address/0xa62a2a75949d25e17c6f08a7818e7be97c18a8d2)
- Ethereum [0xa62a2A75949d25e17C6F08a7818e7bE97c18a8d2](https://etherscan.io/address/0xa62a2A75949d25e17C6F08a7818e7bE97c18a8d2)


Implementation addresses:
- Hermes implementation address (same on both networks): `0x213a1B1d08F2715aE054ade98DEEd8a8F1cc937E`
- Channel implementation address (Polygon): `0x25882f4966065ca13b7bac15cc48391d9a4124f6`
- Channel implementation address (Ethereum): `0xBd20839B331A7A8d10e34CDf7219edf334814c4f`


## Building golang bindings

To be able easily call these smart contract out of any software writen in Go you need to generate golang bindings and import [`payments`](https://github.com/mysteriumnetwork/payments) package into your software.
Expand Down
2 changes: 0 additions & 2 deletions contracts/HermesImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ contract HermesImplementation is FundsRecovery, Utils {
// Approving all myst for dex, because MYST token's `transferFrom` is cheaper when there is approval of uint(-1)
token.approve(_dexAddress, type(uint256).max);
dex = IUniswapV2Router(_dexAddress);

transferOwnership(_operator);
}

function isInitialized() public view returns (bool) {
Expand Down
16 changes: 9 additions & 7 deletions migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,34 @@ const tokenAddr = {
const supportedBlockchains = Object.keys(tokenAddr)

module.exports = async function (deployer, network, accounts) {
const account = accounts[0]

if (supportedBlockchains.includes(network)) {
const parentRegistry = '0x0000000000000000000000000000000000000000'
const tokenAddress = tokenAddr[network]
const swapRouterAddress = '0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff' // uniswap v2 || quickswap router address

// Deploy Channel implementation into blockchain
await deployer.deploy(ChannelImplementation)
await deployer.deploy(ChannelImplementation, { from: account })

// Deploy Registry and Hermes implementation into deterministic address, same on any chain
const minimalHermesStake = web3.utils.toWei(new BN('100'), 'ether') // 100 MYST
const [registryAddress, hermesImplementationAddress] = await deployRegistry(web3, accounts[0])
const [registryAddress, hermesImplementationAddress] = await deployRegistry(web3, account)
const registry = await Registry.at(registryAddress)
await registry.initialize(tokenAddress, swapRouterAddress, minimalHermesStake, ChannelImplementation.address, hermesImplementationAddress, parentRegistry)
await registry.initialize(tokenAddress, swapRouterAddress, minimalHermesStake, ChannelImplementation.address, hermesImplementationAddress, parentRegistry, { from: account })

console.log(' > registry contract address: ', registryAddress)
console.log('\n > registry contract address: ', registryAddress)
console.log(' > hermes implementation address: ', hermesImplementationAddress, '\n')
}
else {
// Deploy WETH token
await WETH.deploy(web3, accounts[0])
await WETH.deploy(web3, account)

// Deploy Uniswap smart contracts: Factory, Router, Migrator
await uniswap.deploy(web3, accounts[0])
await uniswap.deploy(web3, account)

// Deploy Registry and Hermes implementation
const [registryAddress, hermesImplementationAddress] = await deployRegistry(web3, accounts[0])
const [registryAddress, hermesImplementationAddress] = await deployRegistry(web3, account)

console.log(' > registry contract address: ', registryAddress)
console.log(' > hermes implementation address: ', hermesImplementationAddress, '\n')
Expand Down
25 changes: 18 additions & 7 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { BN } = require('web3-utils')

const MystToken = artifacts.require("MystToken")
const Registry = artifacts.require("Registry")
const Hermes = artifacts.require("HermesImplementation")
const deployRegistry = require("../scripts/deployRegistry")

const tokenAddr = {
Expand All @@ -13,27 +14,37 @@ const tokenAddr = {
const supportedBlockchains = Object.keys(tokenAddr)

// Hermes operator is signing hermes payment promises. Change it before actual deployment.
const HERMES_OPERATOR = "0xbFD2D96259De92B5817c83b7E1b756Ba8df1D59D"
const HERMES_OPERATOR = '0x95327DA500eD6841e161A6b369F6fBA4af8EeDD6'
const MEGA_OWNER = '0xC6b139344239b9E33F8dec27DE5Bd7E2a45F0374'

module.exports = async function (deployer, network, accounts) {
const account = accounts[0]

// Run this configurations only on Görli, Mumbai testnets or on Mainnets
if (!supportedBlockchains.includes(network)) {
return
}

const tokenAddress = tokenAddr[network]
const [registryAddress, _] = await deployRegistry(web3, accounts[0])
const [registryAddress, _] = await deployRegistry(web3, account)
const hermesOperator = HERMES_OPERATOR
const token = await MystToken.at(tokenAddress)
const registry = await Registry.at(registryAddress)

// Register hermes with 5000 tokens stake, 20% tx fee and 100 max channel balance
const hermesStake = web3.utils.toWei(new BN('5000'), 'ether') // 5000 tokens
const hermesStake = web3.utils.toWei(new BN('500'), 'ether') // 500 tokens
const hermesFee = 2000 // 20.00%
const minChannelStake = web3.utils.toWei(new BN('1'), 'ether') // 1 token
const minChannelStake = web3.utils.toWei(new BN('0'), 'ether') // 0 token
const maxChannelStake = web3.utils.toWei(new BN('100'), 'ether') // 100 tokens
const url = Buffer.from('68747470733a2f2f6865726d65732e6d797374657269756d2e6e6574776f726b2f', 'hex') // https://hermes.mysterium.network/
await token.approve(registryAddress, hermesStake)
await registry.registerHermes(hermesOperator, hermesStake, hermesFee, minChannelStake, maxChannelStake, url)
console.log('HermesID: ', await registry.getHermesAddress(hermesOperator))
await token.approve(registryAddress, hermesStake, { from: account })
await registry.registerHermes(hermesOperator, hermesStake, hermesFee, minChannelStake, maxChannelStake, url, { from: account })
const hermesAddress = await registry.getHermesAddress(hermesOperator)
console.log('HermesID: ', hermesAddress)

// Set hermes owner
const hermes = await Hermes.at(hermesAddress)
await hermes.transferOwnership(MEGA_OWNER, { from: account })

console.log('Hermes owner: ', await hermes.owner())
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"flatten": "sh flattener.sh",
"deploy-goerli": "truffle deploy --network goerli",
"deploy-mumbai": "truffle deploy --network mumbai",
"deploy-polygon": "truffle deploy --network polygon"
"deploy-polygon": "truffle deploy --network polygon",
"deploy-ethereum": "truffle deploy --network ethereum"
},
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions scripts/deployRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ module.exports = async (web3, account = undefined) => {
}

// Deploy Registry into deterministic address
const registryTxMetadata = generateDeployTx(registryBytecode, 3121666)
const registryTxMetadata = generateDeployTx(registryBytecode, 3123766)
const deployedCode = await web3.eth.getCode(registryTxMetadata.contractAddress)
if (deployedCode.length <= 3) {
await web3.eth.sendTransaction({
from: account, to: registryTxMetadata.sender, value: '312166600000000000'
from: account, to: registryTxMetadata.sender, value: '312376600000000000'
})
await web3.eth.sendSignedTransaction(registryTxMetadata.rawTx)
}

// Deploy HermesImplementation into deterministic address
const hermesTxMetadata = generateDeployTx(hermesBytecode, 3607737)
const hermesTxMetadata = generateDeployTx(hermesBytecode, 3608745)
const deployedHermesCode = await web3.eth.getCode(hermesTxMetadata.contractAddress)
if (deployedHermesCode.length <= 3) {
await web3.eth.sendTransaction({
from: account, to: hermesTxMetadata.sender, value: '360773700000000000'
from: account, to: hermesTxMetadata.sender, value: '360874500000000000'
})
await web3.eth.sendSignedTransaction(hermesTxMetadata.rawTx)
}
Expand Down
9 changes: 5 additions & 4 deletions truffle-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const HDWalletProvider = require("@truffle/hdwallet-provider");
const INFURA_KEY = "...";
const mnemonic = "...";

module.exports = {
// Uncommenting the defaults below
Expand Down Expand Up @@ -45,16 +46,16 @@ module.exports = {
ethereum: {
provider: () => new HDWalletProvider(mnemonic, "https://mainnet.infura.io/v3/"+INFURA_KEY),
network_id: 1,
gas: 5000000,
gasPrice: 100000000000, // 100 Gwei
gas: 4000000,
gasPrice: 80000000000, // 80 Gwei
confirmations: 1,
skipDryRun: true
},
polygon: {
provider: () => new HDWalletProvider(mnemonic, "https://polygon-mainnet.infura.io/v3/"+INFURA_KEY),
network_id: 137,
gas: 5000000,
gasPrice: 50000000000, // 50 Gwei
gas: 4000000,
gasPrice: 40000000000, // 40 Gwei
confirmations: 1,
skipDryRun: true
},
Expand Down

0 comments on commit c3043ea

Please sign in to comment.