Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
How to implement workable (window.ethereum)

I want to inject a provider (window.ethereum) that can make ethers.js web3.js work into the flutter WebView

Now I have implemented the first version, but it doesn't work and can't be recognized by ethers.js or Web3.js

Here is my code

enum RpcMethods {
  eth_requestAccounts = "eth_requestAccounts",
}
interface RequestArguments {
  method: RpcMethods;
  params?: unknown[] | object;
}

function _request({ method, params }: RequestArguments): Promise<any> {
  return _sendToFlutter(method, params);
}
function _connect({ method, params }: RequestArguments): Promise<any> {
  return _sendToFlutter(method, params);
}

function _disconnect({ method, params }: RequestArguments): Promise<any> {
  return _sendToFlutter(method, params);
}

function _isConnected({ method, params }: RequestArguments): Promise<any> {
  return _sendToFlutter(method, params);
}

function _sendToFlutter(rpcMethod: RpcMethods, params?: any) {
  return (<any>globalThis).flutter_inappwebview.callHandler(rpcMethod, params);
}

(<any>globalThis).ethereum = {
  request: _request,
  connect: _connect,
  disconnect: _disconnect,
  isConnected: _isConnected,
};

Call Contract

 const callContract = async () => {
    const contract = new ethers.Contract(
      "0x27998293A37A0662389487214d1cF37E1B319fe3",
      "Contract Abis",
      new ethers.providers.Web3Provider((window as any).ethereum, {
        name: "ETD",
        chainId: 3101,
      }).getSigner()
    );
    const res = await contract.functions.getRecentTokens();
    alert(JSON.stringify(res));
  }

error message:

Uncaught (in promise) TypeError: Cannot read property 'length' of null
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!