Git Product home page Git Product logo

Comments (5)

casey avatar casey commented on July 30, 2024

Also, If you can give some hints for how to do it, I'd be happy to write such an example myself.

from rust-web3.

tomusdrw avatar tomusdrw commented on July 30, 2024

Hi @casey, deploying a contract is as simple as sending transaction without a recipient.
You need a contract deployment bytecode (obtaining it is outside the scope of this library, you can use solc to do that) and you put it in data field of the transaction.

    let bytecode: Vec<u8> = "cafe123456789".parse().unwrap();
    let tx = web3::types::TransactionRequest {
      from: 5.into(),
      to: None,
      gas: Some(125.into()),
      gas_price: None,
      value: None,
      data: Some(bytecode.into()),
      nonce: None,
      condition: None,
    };
    let hash = web3.eth().send_transaction(tx).wait();

from rust-web3.

casey avatar casey commented on July 30, 2024

I'm working on creating an example now, which I'll submit for inclusion once it's done.

One question, if the contract constructor takes a value, how is that value passed in the TransactionRequest?

from rust-web3.

tomusdrw avatar tomusdrw commented on July 30, 2024

Hey! Seems that indeed it's not yet possible without using ethabi externally.
I'll implement a convenience method to deploy a contract tomorrow - it will handle encoding of constructor parameters and sending a transaction.

Thanks for digging into this!

from rust-web3.

casey avatar casey commented on July 30, 2024

Sweet, thank you!

from rust-web3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.