Created
February 11, 2021 19:45
-
-
Save AceVikings/84ac3a2dd792afd5af36fd3d51965133 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.7.4+commit.3f05b770.js&optimize=false&runs=200&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (async () => { | |
| try { | |
| const contractAddress = '0xd8b934580fcE35a11B58C6D73aDeE468a2833fa8' | |
| const accounts = await web3.eth.getAccounts() | |
| console.log('Getting currentOwner') | |
| const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'browser/contracts/artifacts/Owner.json')) | |
| let contract = new web3.eth.Contract(metadata.abi, contractAddress); | |
| contract = contract.methods.getOwner(); | |
| const currentOwner = await contract.call( | |
| { | |
| from: accounts[0] | |
| }) | |
| console.log(currentOwner) | |
| } | |
| catch (e) { | |
| console.log(e.message) | |
| } | |
| })() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Right click on the script name and hit "Run" to execute | |
| (async () => { | |
| try { | |
| console.log('Running deployWithWeb3 script...') | |
| const contractName = 'Owner' // Change this for other contract | |
| const constructorArgs = [] // Put constructor args (if any) here for your contract | |
| // Note that the script needs the ABI which is generated from the compilation artifact. | |
| // Make sure contract is compiled and artifacts are generated | |
| const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path | |
| const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) | |
| const accounts = await web3.eth.getAccounts() | |
| let contract = new web3.eth.Contract(metadata.abi) | |
| contract = contract.deploy({ | |
| data: metadata.data.bytecode.object, | |
| arguments: constructorArgs | |
| }) | |
| const newContractInstance = await contract.send({ | |
| from: accounts[0], | |
| gas: 1500000, | |
| gasPrice: '30000000000' | |
| }) | |
| console.log('Contract deployed at address: ', newContractInstance.options.address) | |
| } catch (e) { | |
| console.log(e.message) | |
| } | |
| })() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (async () => { | |
| let string = "Hallo World" | |
| let b32 = ethers.utils.formatBytes32String(string) | |
| console.log(b32) | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment