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

[Bug] wasm erc20 token transfer not working #1095

Closed
skutcher opened this issue Jul 23, 2024 · 6 comments
Closed

[Bug] wasm erc20 token transfer not working #1095

skutcher opened this issue Jul 23, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@skutcher
Copy link

Component

contract, transports

What version of Alloy are you on?

├── alloy v0.2.0 │ ├── alloy-contract v0.2.0 │ │ ├── alloy-dyn-abi v0.7.7 │ │ │ ├── alloy-json-abi v0.7.7 │ │ │ │ ├── alloy-primitives v0.7.7 │ │ │ │ │ ├── alloy-rlp v0.3.7 │ │ │ │ │ │ ├── alloy-rlp-derive v0.3.7 (proc-macro) │ │ │ │ │ │ ├── alloy-rlp v0.3.7 () │ │ │ │ ├── alloy-sol-type-parser v0.7.7 │ │ │ ├── alloy-primitives v0.7.7 () │ │ │ ├── alloy-sol-type-parser v0.7.7 () │ │ │ ├── alloy-sol-types v0.7.7 │ │ │ │ ├── alloy-json-abi v0.7.7 () │ │ │ │ ├── alloy-primitives v0.7.7 () │ │ │ │ ├── alloy-sol-macro v0.7.7 (proc-macro) │ │ │ │ │ ├── alloy-sol-macro-expander v0.7.7 │ │ │ │ │ │ ├── alloy-json-abi v0.7.7 │ │ │ │ │ │ │ ├── alloy-primitives v0.7.7 │ │ │ │ │ │ │ ├── alloy-sol-type-parser v0.7.7 │ │ │ │ │ │ ├── alloy-sol-macro-input v0.7.7 │ │ │ │ │ │ │ ├── alloy-json-abi v0.7.7 () │ │ │ │ │ ├── alloy-sol-macro-input v0.7.7 () │ │ ├── alloy-json-abi v0.7.7 () │ │ ├── alloy-network v0.2.0 │ │ │ ├── alloy-consensus v0.2.0 │ │ │ │ ├── alloy-eips v0.2.0 │ │ │ │ │ ├── alloy-primitives v0.7.7 () │ │ │ │ │ ├── alloy-rlp v0.3.7 () │ │ │ │ │ ├── alloy-serde v0.2.0 │ │ │ │ │ │ ├── alloy-primitives v0.7.7 () │ │ │ │ ├── alloy-primitives v0.7.7 () │ │ │ │ ├── alloy-rlp v0.3.7 () │ │ │ │ ├── alloy-serde v0.2.0 () │ │ │ ├── alloy-eips v0.2.0 () │ │ │ ├── alloy-json-rpc v0.2.0 │ │ │ │ ├── alloy-primitives v0.7.7 () │ │ │ ├── alloy-primitives v0.7.7 () │ │ │ ├── alloy-rpc-types-eth v0.2.0 │ │ │ │ ├── alloy-consensus v0.2.0 () │ │ │ │ ├── alloy-eips v0.2.0 () │ │ │ │ ├── alloy-primitives v0.7.7 () │ │ │ │ ├── alloy-rlp v0.3.7 () │ │ │ │ ├── alloy-serde v0.2.0 () │ │ │ │ ├── alloy-sol-types v0.7.7 () │ │ │ ├── alloy-serde v0.2.0 () │ │ │ ├── alloy-signer v0.2.0 │ │ │ │ ├── alloy-primitives v0.7.7 () │ │ │ ├── alloy-sol-types v0.7.7 () │ │ ├── alloy-primitives v0.7.7 () │ │ ├── alloy-provider v0.2.0 │ │ │ ├── alloy-chains v0.1.23 │ │ │ ├── alloy-consensus v0.2.0 () │ │ │ ├── alloy-eips v0.2.0 () │ │ │ ├── alloy-json-rpc v0.2.0 () │ │ │ ├── alloy-network v0.2.0 () │ │ │ ├── alloy-primitives v0.7.7 () │ │ │ ├── alloy-rpc-client v0.2.0 │ │ │ │ ├── alloy-json-rpc v0.2.0 () │ │ │ │ ├── alloy-transport v0.2.0 │ │ │ │ │ ├── alloy-json-rpc v0.2.0 () │ │ │ │ ├── alloy-transport-http v0.2.0 │ │ │ │ │ ├── alloy-json-rpc v0.2.0 () │ │ │ │ │ ├── alloy-transport v0.2.0 () │ │ │ ├── alloy-rpc-types-eth v0.2.0 () │ │ │ ├── alloy-transport v0.2.0 () │ │ │ ├── alloy-transport-http v0.2.0 () │ │ ├── alloy-rpc-types-eth v0.2.0 () │ │ ├── alloy-sol-types v0.7.7 () │ │ ├── alloy-transport v0.2.0 () │ ├── alloy-core v0.7.7 │ │ ├── alloy-dyn-abi v0.7.7 () │ │ ├── alloy-json-abi v0.7.7 () │ │ ├── alloy-primitives v0.7.7 () │ │ └── alloy-sol-types v0.7.7 () │ ├── alloy-eips v0.2.0 () │ ├── alloy-provider v0.2.0 () │ └── alloy-rpc-client v0.2.0 (*)

Operating System

Linux

Describe the bug

I try todo an erc20 token transfer with target wasm32-unknown-unknown.
contract total supply as well as contract balance of works perfect.
but as soon as i call
contract.transfer("to_adress", "token_amount).from("my_address").send().await

i got the following error message in the browser console:

panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-transport-0.2.0/src/utils.rs:56:9:
The 'wasm-bindgen' feature must be enabled

I have already added wasm bindgen to the future list in my Cargo.toml, but this changed nothing:

alloy = { version = "0.2", features = ["providers", "sol-types", "json", "contract", "wasm-bindgen"] }

@skutcher skutcher added the bug Something isn't working label Jul 23, 2024
@DaniPopes
Copy link
Member

Can you try enabling "transports" feature too?

@skutcher
Copy link
Author

skutcher commented Jul 24, 2024

Can you try enabling "transports" feature too?

sure than i got this at exactly the same line within the code

panicked at library/std/src/sys/pal/wasm/../unsupported/time.rs:13:9:
time not implemented on this platform

@mickvandijke
Copy link

Can you try enabling "transports" feature too?

sure than i got this at exactly the same line within the code

panicked at library/std/src/sys/pal/wasm/../unsupported/time.rs:13:9:
time not implemented on this platform

I'm having the same problem.. Did someone find a fix for this?

I think it is caused by Alloy using std::time instead of something like https://github.com/daxpedda/web-time . std::time is not WASM compatible.

@b-zee
Copy link
Contributor

b-zee commented Oct 3, 2024

I ran into the same trouble with alloy. I have been using the wasm-bindgen feature, but that wasn't enough.

I have made a fork with patches that seem to work for me: https://github.com/b-zee/alloy/tree/fix-wasm-instant

See the patch here (it's unfortunately based on the 0.2.1 we depend on): v0.2.1...b-zee:alloy:fix-wasm-instant

Essentially it's a patch changing to depend on wasmtimer in the places I encountered a runtime error, e.g.:

#[cfg(target_arch = "wasm32")]
use wasmtimer::{std::Instant, tokio::sleep_until};

@DaniPopes, do you think the above is suitable for a PR? We'd love to publish a package soon and it would be awesome if the patch can be included in a future release of alloy.

@DaniPopes
Copy link
Member

Sure, feel free!

@b-zee
Copy link
Contributor

b-zee commented Oct 3, 2024

Great, I've put in a PR: #1426

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants