-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
duplicateDuplicate of another issue.Duplicate of another issue.v6Issues regarding v6Issues regarding v6
Description
Ethers Version
6.0.2
Search Terms
cloudflare, code generation, Code generation from strings disallowed for this context
Describe the Problem
When using CloudFlare Workers I can't call methods on a contract.
A simple await contract.balanceOf(wallet.address).call() doesn't work in my case.
The error I get is Code generation from strings disallowed for this context.
Ideally, this would get solved in the package itself (if it is even related to an internal bug).
Otherwise, if I need to use a workaround that would be totally fine too.
Code Snippet
const { JsonRpcProvider, Contract, Wallet, formatEther } = await import('ethers');
const abi = ['function balanceOf(address account) external view returns (uint)'];
const provider = new JsonRpcProvider("https://polygon-rpc.com");
const wallet = new Wallet(env.PRIVATE_KEY, provider);
const contract = new Contract("someAddress", abi, provider);
const result = await contract.balanceOf(wallet.address).call()Contract ABI
['function balanceOf(address account) external view returns (uint)']Errors
✘ [ERROR] Uncaught (in promise) EvalError: Code generation from strings disallowed for this context
super();
^
at WrappedMethod
(/Users/redacted/redacted/redacted/node_modules/ethers/src.ts/contract/contract.ts:250:8)
at getFunction
(/Users/redacted/redacted/redacted/node_modules/ethers/src.ts/contract/contract.ts:767:28)
at get
(/Users/redacted/redacted/redacted/node_modules/ethers/src.ts/contract/contract.ts:705:38)Environment
Other (please specify)
Environment (Other)
CloudFlare Workers
Metadata
Metadata
Assignees
Labels
duplicateDuplicate of another issue.Duplicate of another issue.v6Issues regarding v6Issues regarding v6