Code Monkey home page Code Monkey logo

hedera-hardhat-example-project's People

Contributors

neurone avatar simihunjan avatar theekrystallee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hedera-hardhat-example-project's Issues

Error interacting with contract: TypeError: Cannot read properties of undefined (reading 'publicKey')

Description

hey,

i've been trying to deploy my smart contract on the hedera testnet account (ECDSA), followed all the steps mentioned in the readme.md file, all the environment variables have been set as mentioned but i still keep encountering this error.

when i run npx hardhat test the tests pass, but when i try to interact with the contract again gives me this error:

Issue

node uploadToHedera.js
OK till here Error interacting with contract: TypeError: Cannot read properties of undefined (reading 'publicKey') at NodeClient.setOperator (C:\Users\bawgi\OneDrive\Documents\DEHRSys\dehrsys\node_modules\@hashgraph\sdk\lib\client\Client.cjs:286:48) at interactWithContract (C:\Users\bawgi\OneDrive\Documents\DEHRSys\dehrsys\uploadToHedera.js:28:16) at Object.<anonymous> (C:\Users\bawgi\OneDrive\Documents\DEHRSys\dehrsys\uploadToHedera.js:44:1) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) at node:internal/main/run_main_module:17:47

i believe the issue is occurring in the \node_modules\@hashgraph\sdk\lib\client\Client.cjs:286:48 file.

the code that is triggering the error:

const { Client, ContractCallQuery } = require("@hashgraph/sdk");

var contractAddress = "0x5c755dDFFBD0B6405DE612Bc96609d21C129917c";

async function interactWithContract(moralisHash) {
    try {
        const client = Client.forTestnet();
        console.log("OK till here")
        client.setOperator(process.env.ACCOUNT_ID, process.env.TESTNET_OPERATOR_PRIVATE_KEY);

        const contract = await new ContractCallQuery()
            .setContractId(contractAddress)
            .setGas(30000)
            .setFunction("changeHash")
            .addString(moralisHash)
            .execute(client);

        console.log("Transaction ID:", contract.transactionId);
    } catch (error) {
        console.error("Error interacting with contract:", error);
    }
}

const moralisHash = "https://ipfs.moralis.io:2053/ipfs/QmQvASqTFsJxNqym55KTm98FVWxwCD9cKt37ba6kYT962z/trainmedications.json";
interactWithContract(moralisHash);

Environment

  • @hashgraph/hedera-local: v2.18.0
  • @nomicfoundation/hardhat-toolbox: v2.0.1
  • dotenv: v16.3.1
  • fs: v0.0.1-security
  • moralis: v2.23.2

Steps to reproduce

node index.js to obtain the hash by Moralis Web3 to store in the uploadToHedera.js file.
npx hardhat compile
npx hardhat deploy-contract
npx hardhat test
node uploadToHedera.js

Additional context

No response

Hedera network

testnet

Version

Hardhat: v2.12.6

Operating system

Windows

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.