hashgraph / hedera-hardhat-example-project Goto Github PK
View Code? Open in Web Editor NEWAn example Hedera Hardhat project where you can use an instance of the Hedera JSON RPC Relay to test and deploy a smart contract.
An example Hedera Hardhat project where you can use an instance of the Hedera JSON RPC Relay to test and deploy a smart contract.
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:
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);
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
No response
testnet
Hardhat: v2.12.6
Windows
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.