parent
9cc0299aca
commit
d7ab51f366
@ -1,16 +0,0 @@ |
|||||||
export default async () => { |
|
||||||
return { |
|
||||||
// @ts-ignore
|
|
||||||
'contracts/SampleERC20.sol': (await import('raw-loader!./contracts/SampleERC20.sol')).default, |
|
||||||
// @ts-ignore
|
|
||||||
'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, |
|
||||||
// @ts-ignore
|
|
||||||
'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, |
|
||||||
// @ts-ignore
|
|
||||||
'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, |
|
||||||
// @ts-ignore
|
|
||||||
'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, |
|
||||||
// @ts-ignore
|
|
||||||
'tests/SampleERC20_test.sol': (await import('raw-loader!./tests/SampleERC20_test.sol')).default |
|
||||||
} |
|
||||||
} |
|
@ -1,26 +0,0 @@ |
|||||||
import { ethers } from 'ethers' |
|
||||||
|
|
||||||
export const deploy = async (contractName: string, args: Array<any>, from?: string): Promise<any> => {
|
|
||||||
|
|
||||||
console.log(`deploying ${contractName}`) |
|
||||||
// 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` |
|
||||||
|
|
||||||
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) |
|
||||||
// 'web3Provider' is a remix global variable object
|
|
||||||
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() |
|
||||||
|
|
||||||
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); |
|
||||||
|
|
||||||
let contract |
|
||||||
if (from) { |
|
||||||
contract = await factory.connect(from).deploy(...args); |
|
||||||
} else { |
|
||||||
contract = await factory.deploy(...args); |
|
||||||
}
|
|
||||||
|
|
||||||
// The contract is NOT deployed yet; we must wait until it is mined
|
|
||||||
await contract.deployed() |
|
||||||
return contract |
|
||||||
} |
|
@ -1,27 +0,0 @@ |
|||||||
import Web3 from 'web3' |
|
||||||
|
|
||||||
export const deploy = async (contractName: string, args: Array<any>, from?: string, gas?: number): Promise<any> => { |
|
||||||
|
|
||||||
const web3 = new Web3(window.web3Provider) |
|
||||||
console.log(`deploying ${contractName}`) |
|
||||||
// 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` |
|
||||||
|
|
||||||
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: args |
|
||||||
}) |
|
||||||
|
|
||||||
const newContractInstance = await contract.send({ |
|
||||||
from: from || accounts[0], |
|
||||||
gas: gas || 1500000 |
|
||||||
}) |
|
||||||
return newContractInstance.options
|
|
||||||
} |
|
Loading…
Reference in new issue