eth-crypto
Version:
Cryptographic functions for ethereum and how to use them with web3 and solidity
18 lines (13 loc) • 460 B
JavaScript
import { ContractFactory } from 'ethers';
export async function txDataByCompiled(
abi,
bytecode,
args
) {
// solc returns a string which is often passed instead of the json
if (typeof abi === 'string') abi = JSON.parse(abi);
// Construct a Contract Factory
const factory = new ContractFactory(abi, '0x' + bytecode);
const deployTransaction = await factory.getDeployTransaction(...args);
return deployTransaction.data;
}