I am trying to deploy my contract onto the blockchain in my private network with local private key (no wallet: I used web3.auto.w3.account.create()).

I know how to send normal transaction with local private key. But deploying contract is not easy for me. I am using web3.py

>>> from web3.auto import w3
>>> account = w3.eth.account.create()
>>> account.address
>>> account.privateKey

I get address and private key. so what I want to do is ...

web3 = Web3(Web3.HTTPProvider(""))

contract_src = open('Funding.sol').read()
contract_bin = compile_source(contract_src)
contract_interface = contract_bin['<stdin>:Funding']

transaction = {
    'from': <public address which I got>,
    'gas': 100000,
    'gasPrice': 0,
    'nonce': 0,
signed = w3.eth.account.signTransaction(transaction, <private key which I got>)

In transaction, what information should I put in ??

My contract looks like below:

contract Information {
    String str;

    function modify(String s) public {
        str = s;

contract Bag {
    mapping(uint256 => Bag) contents;
    uint256 public i = 0;

    function create() public {
        contents[i++] = new Information();

1 Answer 1


What you are trying to do is feasible and should work. your contract doesn't really matter that much other than the arguments to end for the function you are calling.

What you put in transaction is the transaction object, you can find it here : https://web3js.readthedocs.io/en/1.0/web3-eth.html?highlight=transaction#id62

The data Attribute of the transaction object is the ABI encoded function with it's argument, you can get it via this example : https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#id31

myContract.methods.myMethod(123).encodeABI(); '0x58cf5f1000000000000000000000000000000000000000000000000000000000000007B

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.