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:

Rxjs Adoption Guide: Overview, Examples, And Alternatives

RxJS adoption guide: Overview, examples, and alternatives

Get to know RxJS features, benefits, and more to help you understand what it is, how it works, and why you should use it.

Emmanuel Odioko
Jul 26, 2024 â‹… 13 min read
Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 â‹… 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 â‹… 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 2024 â‹… 5 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