diff --git a/README.md b/README.md index db7a563..249279b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/contracts/HermesImplementation.sol b/contracts/HermesImplementation.sol index 1cffa9b..640faae 100644 --- a/contracts/HermesImplementation.sol +++ b/contracts/HermesImplementation.sol @@ -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) { diff --git a/migrations/1_initial_migration.js b/migrations/1_initial_migration.js index 5fc0147..1541332 100644 --- a/migrations/1_initial_migration.js +++ b/migrations/1_initial_migration.js @@ -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') diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index da27954..f6b4630 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -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 = { @@ -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()) } diff --git a/package.json b/package.json index 558c35f..f90d0e0 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/deployRegistry.js b/scripts/deployRegistry.js index f996848..a8fdd81 100644 --- a/scripts/deployRegistry.js +++ b/scripts/deployRegistry.js @@ -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) } diff --git a/truffle-config.js b/truffle-config.js index 9a4caed..b783992 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -1,5 +1,6 @@ const HDWalletProvider = require("@truffle/hdwallet-provider"); const INFURA_KEY = "..."; +const mnemonic = "..."; module.exports = { // Uncommenting the defaults below @@ -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 },