tomusdrw / rust-web3

Ethereum JSON-RPC multi-transport client. Rust implementation of web3 library. ENS address: rust-web3.eth
MIT License
1.45k stars 465 forks source link

How to structure data for contract.signed_call #619

Closed romanzac closed 2 years ago

romanzac commented 2 years ago

Hi there,

May I get some help with data structure ? I am getting rejected by blockchain API on invalid data.

My ABI is:

{"constant":false,"inputs":[{"name":"index","type":"uint256"}],"name":"forceWithdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}

My call is:

let withdraw_res = sc.signed_call( "forceWithdraw", Tokenize::into_tokens("100000000".to_string()), Options::default(), SecretKeyRef::new(&prvk)) .await .unwrap();

reeslabree commented 2 years ago

Were you ever able to figure this out? Would appreciate some guidance since the documentation is pretty sparse.

romanzac commented 2 years ago

Yes, I moved over to another library: https://crates.io/crates/ethers
Supportive community. I am happy using it.

reeslabree commented 2 years ago

Lol. If anyone should happen to stumble across this in the future, there's something up with the versioning on secp256k1.

To get this to work, you must use secp256k1 = "0.21.1" in your toml, and the key must be typed as let prvk: secp256k1::SecretKey = .... The key parameter in signed_call is then SecretKeyRef::new(&prvk)).