Comments (5)
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.
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.
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.
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.
Sweet, thank you!
from rust-web3.
Related Issues (20)
- Ownership transfer HOT 3
- Runtime error: revert when deploy contract to ganache local test node
- Contract call return value parsing problem HOT 1
- Transfer ERC20 Tokens Using Contracts
- feat: webSockets reconnecting
- issues with return value type - array of tuples
- windows https/wss connection
- Cannot use query for complex return data (nested tuples) HOT 1
- Request for existing block ends up with None to be returned HOT 1
- Write a smart contract using a private key in `[u8; 32]` format
- is there a way to callStatic func like in ethers.js? HOT 1
- Block number doesn't have Safe
- Unable to convert web3::contract::error to web3::error
- how to pass tuple data as Parameters to contract.query()
- Correct word in docs.rs
- Make block() support BlockNumber as a parameter. HOT 1
- Add an option to run without depending on openssl HOT 1
- Upgrade from `ethabi` to `alloy-json-abi`
- Cannot compile v0.19.0 with Rust v1.77 on Mac HOT 2
- How to use reqwest client with tracing?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-web3.