Skip to main content
deleted 2 characters in body
Source Link
hardfork
  • 163
  • 1
  • 8

If you are using a newer version of web3 (version 1.0.0 for example):

 // example solidity code
 function ContractName(address _arg1, uint256 _arg2, uint256 _arg3) public {
    arg1 = _arg1;
    arg2 = _arg2;
    arg3 = _arg3;
  }

Use web3.eth.abi.encodeParameter() oderor web3.eth.abi.encodeParameters() to encode your parameters and concatenate them at the end of your bytecode.

const Web3 = require("web3");
const solc = require("solc");

// compile the solidity code
let compiled = solc.compile(source);

// save public interface of contract
let abi = JSON.parse(compiled.contracts[":ContractName"].interface)

// create var with contract
let CrowdFunding = new web3.eth.Contract(abi);

let bytecodeWithParameters = compiled.contracts[':ContractName'].bytecode + web3.eth.abi.encodeParameters(['address', 'uint256', 'uint256'], ['0x08cf02070bb9f167556c677da58e6678bbe871fc', '100000000000000000', '10000']).slice(2);
// slice(2) because we want to remove the '0x' at the beginning.

Now, you can enter bytecodeWithParameters on https://www.myetherwallet.com/#contracts to deploy it with its parameters for example.

If you are using a newer version of web3 (version 1.0.0 for example):

 // example solidity code
 function ContractName(address _arg1, uint256 _arg2, uint256 _arg3) public {
    arg1 = _arg1;
    arg2 = _arg2;
    arg3 = _arg3;
  }

Use web3.eth.abi.encodeParameter() oder web3.eth.abi.encodeParameters() to encode your parameters and concatenate them at the end of your bytecode.

const Web3 = require("web3");
const solc = require("solc");

// compile the solidity code
let compiled = solc.compile(source);

// save public interface of contract
let abi = JSON.parse(compiled.contracts[":ContractName"].interface)

// create var with contract
let CrowdFunding = new web3.eth.Contract(abi);

let bytecodeWithParameters = compiled.contracts[':ContractName'].bytecode + web3.eth.abi.encodeParameters(['address', 'uint256', 'uint256'], ['0x08cf02070bb9f167556c677da58e6678bbe871fc', '100000000000000000', '10000']).slice(2);
// slice(2) because we want to remove the '0x' at the beginning.

Now, you can enter bytecodeWithParameters on https://www.myetherwallet.com/#contracts to deploy it with its parameters for example.

If you are using a newer version of web3 (version 1.0.0 for example):

 // example solidity code
 function ContractName(address _arg1, uint256 _arg2, uint256 _arg3) public {
    arg1 = _arg1;
    arg2 = _arg2;
    arg3 = _arg3;
  }

Use web3.eth.abi.encodeParameter() or web3.eth.abi.encodeParameters() to encode your parameters and concatenate them at the end of your bytecode.

const Web3 = require("web3");
const solc = require("solc");

// compile the solidity code
let compiled = solc.compile(source);

// save public interface of contract
let abi = JSON.parse(compiled.contracts[":ContractName"].interface)

// create var with contract
let CrowdFunding = new web3.eth.Contract(abi);

let bytecodeWithParameters = compiled.contracts[':ContractName'].bytecode + web3.eth.abi.encodeParameters(['address', 'uint256', 'uint256'], ['0x08cf02070bb9f167556c677da58e6678bbe871fc', '100000000000000000', '10000']).slice(2);
// slice(2) because we want to remove the '0x' at the beginning.

Now, you can enter bytecodeWithParameters on https://www.myetherwallet.com/#contracts to deploy it with its parameters for example.

deleted 53 characters in body
Source Link
hardfork
  • 163
  • 1
  • 8

If you are using a newer version of web3 (version 1.0.0 for example):

 // example solidity code
 function ContractName(address _arg1, uint256 _arg2, uint256 _arg3) public {
    arg1 = _arg1;
    arg2 = _arg2;
    arg3 = _arg3;
  }

Use web3.eth.abi.encodeParameter() oder web3.eth.abi.encodeParameters() to encode your parameters and concatenate the encoded parametersthem at the end of your bytecode.

const Web3 = require("web3");
const solc = require("solc");

// compile the solidity code
let compiled = solc.compile(source);

// save public interface of contract
let abi = JSON.parse(compiled.contracts[":ContractName"].interface)

// create var with contract
let CrowdFunding = new web3.eth.Contract(abi);

let x = "";
xbytecodeWithParameters = x + compiled.contracts[':ContractName'].bytecode
x = x + web3.eth.abi.encodeParameterencodeParameters('address'['address', '0x08cf02070bb9f167556c677da58e6678bbe871fc').slice(2);
x = x'uint256', +'uint256'], web3.eth.abi.encodeParameter('uint256'['0x08cf02070bb9f167556c677da58e6678bbe871fc', '100000000000000000', '10000']).slice(2);
x// =slice(2) xbecause +we web3.eth.abi.encodeParameter('uint256',want '10000')to remove the '0x' at the beginning.slice(2);

Now, you can enter deplay xbytecodeWithParameters on https://www.myetherwallet.com/#contracts to deploy it with its parameters for example.

If you are using a newer version of web3 (version 1.0.0 for example):

 // example solidity code
 function ContractName(address _arg1, uint256 _arg2, uint256 _arg3) public {
    arg1 = _arg1;
    arg2 = _arg2;
    arg3 = _arg3;
  }

Use web3.eth.abi.encodeParameter() to encode your parameters and concatenate the encoded parameters at the end of your bytecode.

const Web3 = require("web3");
const solc = require("solc");

// compile the solidity code
let compiled = solc.compile(source);

// save public interface of contract
let abi = JSON.parse(compiled.contracts[":ContractName"].interface)

// create var with contract
let CrowdFunding = new web3.eth.Contract(abi);

let x = "";
x = x + compiled.contracts[':ContractName'].bytecode
x = x + web3.eth.abi.encodeParameter('address', '0x08cf02070bb9f167556c677da58e6678bbe871fc').slice(2);
x = x + web3.eth.abi.encodeParameter('uint256', '100000000000000000').slice(2);
x = x + web3.eth.abi.encodeParameter('uint256', '10000').slice(2);

Now, you can enter deplay x on https://www.myetherwallet.com/#contracts for example.

If you are using a newer version of web3 (version 1.0.0 for example):

 // example solidity code
 function ContractName(address _arg1, uint256 _arg2, uint256 _arg3) public {
    arg1 = _arg1;
    arg2 = _arg2;
    arg3 = _arg3;
  }

Use web3.eth.abi.encodeParameter() oder web3.eth.abi.encodeParameters() to encode your parameters and concatenate them at the end of your bytecode.

const Web3 = require("web3");
const solc = require("solc");

// compile the solidity code
let compiled = solc.compile(source);

// save public interface of contract
let abi = JSON.parse(compiled.contracts[":ContractName"].interface)

// create var with contract
let CrowdFunding = new web3.eth.Contract(abi);

let bytecodeWithParameters = compiled.contracts[':ContractName'].bytecode + web3.eth.abi.encodeParameters(['address', 'uint256', 'uint256'], ['0x08cf02070bb9f167556c677da58e6678bbe871fc', '100000000000000000', '10000']).slice(2);
// slice(2) because we want to remove the '0x' at the beginning.

Now, you can enter bytecodeWithParameters on https://www.myetherwallet.com/#contracts to deploy it with its parameters for example.

Source Link
hardfork
  • 163
  • 1
  • 8

If you are using a newer version of web3 (version 1.0.0 for example):

 // example solidity code
 function ContractName(address _arg1, uint256 _arg2, uint256 _arg3) public {
    arg1 = _arg1;
    arg2 = _arg2;
    arg3 = _arg3;
  }

Use web3.eth.abi.encodeParameter() to encode your parameters and concatenate the encoded parameters at the end of your bytecode.

const Web3 = require("web3");
const solc = require("solc");

// compile the solidity code
let compiled = solc.compile(source);

// save public interface of contract
let abi = JSON.parse(compiled.contracts[":ContractName"].interface)

// create var with contract
let CrowdFunding = new web3.eth.Contract(abi);

let x = "";
x = x + compiled.contracts[':ContractName'].bytecode
x = x + web3.eth.abi.encodeParameter('address', '0x08cf02070bb9f167556c677da58e6678bbe871fc').slice(2);
x = x + web3.eth.abi.encodeParameter('uint256', '100000000000000000').slice(2);
x = x + web3.eth.abi.encodeParameter('uint256', '10000').slice(2);

Now, you can enter deplay x on https://www.myetherwallet.com/#contracts for example.