2022-01-28
2133
#blockchain#node#react
Zafar Saleem
89188
Jan 28, 2022 â‹… 7 min read

Interact with smart contracts via React and a Node.js API

Zafar Saleem I've worked as a developer on projects spanning from small-scale websites to large-scale applications both in small and large companies.

Recent posts:

TypeScript logo over a pink and white background.

Drizzle vs. Prisma: Which ORM is best for your project?

Compare Prisma and Drizzle ORMs to learn their differences, strengths, and weaknesses for data access and migrations.

Temitope Oyedele
Nov 21, 2024 â‹… 10 min read
Practical Implementation Of The Rule Of Least Power For Developers

Practical implementation of the Rule of Least Power for developers

It’s easy for devs to default to JavaScript to fix every problem. Let’s use the RoLP to find simpler alternatives with HTML and CSS.

Timonwa Akintokun
Nov 21, 2024 â‹… 8 min read
Rust logo over black marble background.

Handling memory leaks in Rust

Learn how to manage memory leaks in Rust, avoid unsafe behavior, and use tools like weak references to ensure efficient programs.

Ukeje Goodness
Nov 20, 2024 â‹… 4 min read
Robot pretending to be a person.

Using curl-impersonate in Node.js to avoid blocks

Bypass anti-bot measures in Node.js with curl-impersonate. Learn how it mimics browsers to overcome bot detection for web scraping.

Antonello Zanini
Nov 20, 2024 â‹… 13 min read
View all posts

8 Replies to "Interact with smart contracts via React and a Node.js API"

  1. getting error

    Error: Returned values aren’t valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI
    for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
    at ABICoder.decodeParametersWith

    1. Please check if you are using the correct ABI from the smart contract and secondly check if you have enough Gas in your Metamask Wallet.

  2. You are supposed to use correct ABI. Please check that. Secondly, check do you have enough Gas in your Metamask wallet.

  3. Hi Zafar, I’m trying to run the server.js, I don’t have express or web3 or mongoDB, do I need more? I’m trying to install those like npm install express and I get this error:

    npm ERR! code EINVALIDPACKAGENAME
    npm ERR! Invalid package name “.pnpm”: name cannot start with a period

  4. Excellent article.

    The nodemon server.js command does not run and the error below appears. I did exactly as in the tutorial and copied exactly the same codes.

    Also, running “yarn start” it opens “http://localhost:3000/” with no information, blank page.

    Detail: the contract was implemented and its address correctly changed in the code.


    PS D:\MyDocs\Cripto\Scripts\frontend-to-contract\blockchain-node-api> nodemon server.js
    [nodemon] 2.0.19
    [nodemon] to restart at any time, enter `rs`
    [nodemon] watching path(s): *.*
    [nodemon] watching extensions: js,mjs,json
    [nodemon] starting `node server.js`
    internal/modules/cjs/loader.js:905
    throw err;
    ^

    Error: Cannot find module ‘express’
    Require stack:
    – D:\MyDocs\Cripto\Scripts\frontend-to-contract\blockchain-node-api\server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object. (D:\MyDocs\Cripto\Scripts\frontend-to-contract\blockchain-node-api\server.js:1:17)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
    code: ‘MODULE_NOT_FOUND’,
    requireStack: [
    ‘D:\\MyDocs\\Cripto\\Scripts\\frontend-to-contract\\blockchain-node-api\\server.js’
    ]
    }
    [nodemon] app crashed – waiting for file changes before starting…

Leave a Reply