Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime error: revert when deploy contract to ganache local test node #667

Open
songtianyi opened this issue Sep 27, 2022 · 0 comments
Open

Comments

@songtianyi
Copy link

I'm running a ganache local testnet to test rust-web3 contract deployment example.

ganache --logging.verbose

And I didn't change the code logic exception the network and accounts

rust-web3 on  master [!?] is 📦 v0.19.0 via 🦀 v1.61.0
❯ git diff
diff --git a/examples/contract.rs b/examples/contract.rs
index c45e7aa..968b6ac 100644
--- a/examples/contract.rs
+++ b/examples/contract.rs
@@ -10,7 +10,8 @@ async fn main() -> web3::contract::Result<()> {
     let http = web3::transports::Http::new("http://localhost:8545")?;
     let web3 = web3::Web3::new(http);

-    let my_account = hex!("d028d24f16a8893bd078259d413372ac01580769").into();
+    // let my_account = hex!("d028d24f16a8893bd078259d413372ac01580769").into();
+    let my_account = web3.eth().accounts().await.unwrap().get(0).unwrap().clone();
     // Get the contract bytecode for instance from Solidity compiler
     let bytecode = include_str!("./res/contract_token.code").trim_end();
     // Deploying a contract
@@ -18,7 +19,7 @@ async fn main() -> web3::contract::Result<()> {
         .confirmations(0)
         .options(Options::with(|opt| {
             opt.value = Some(5.into());
-            opt.gas_price = Some(5.into());
+            opt.gas_price = Some(875000000.into());
             opt.gas = Some(3_000_000.into());
         }))
         .execute(

When I run this example error happened

Transaction: 0xbec3276a41fa94f2a55a8e75f09ae17906787fb7aee8f870be4afd9dbe2d2bfb
  Contract created: 0xdf0a17753b9dbf6b0e7576c385462d506d38c7c6
  Gas usage: 116175
  Block number: 1
  Block time: Tue Sep 27 2022 13:07:58 GMT+0800 (中国标准时间)
  Runtime error: revert

   >  eth_getTransactionReceipt: [
   >   "0xbec3276a41fa94f2a55a8e75f09ae17906787fb7aee8f870be4afd9dbe2d2bfb"
   > ]
   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant