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:

Building a Full-Featured Laravel Admin Dashboard with Filament

Building a full-featured Laravel admin dashboard with Filament

Build scalable admin dashboards with Filament and Laravel using Form Builder, Notifications, and Actions for clean, interactive panels.

Kayode Adeniyi
Dec 20, 2024 â‹… 5 min read
Working With URLs In JavaScript

Working with URLs in JavaScript

Break down the parts of a URL and explore APIs for working with them in JavaScript, parsing them, building query strings, checking their validity, etc.

Joe Attardi
Dec 19, 2024 â‹… 6 min read
Lazy Loading Vs. Eager Loading

Lazy loading vs. Eager loading

In this guide, explore lazy loading and error loading as two techniques for fetching data in React apps.

Njong Emy
Dec 18, 2024 â‹… 5 min read
Deno logo over an orange background

How to migrate your Node.js app to Deno 2.0

Deno is a popular JavaScript runtime, and it recently launched version 2.0 with several new features, bug fixes, and improvements […]

Yashodhan Joshi
Dec 17, 2024 â‹… 7 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