Lesson 5: Updated Favorite number is: [object Promise] #1582
Answered
by
othaime-en
eli5mecoding
asked this question in
Q&A
-
I'm getting const ethers = require("ethers"); // aqui estamos importando a library Ethers
const fs = require("fs-extra");
async function main() {
const provider = new ethers.providers.JsonRpcProvider(
"http://127.0.0.1:7545"
);
const wallet = new ethers.Wallet(
"4e4c82035b4ba6db4148e6bc153e3ebbb335b2aaa45f12699049f0612113b711",
provider
);
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
const binary = fs.readFileSync(
"./SimpleStorage_sol_SimpleStorage.bin",
"utf8"
);
const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
console.log("Deploying, please wait...");
const contract = await contractFactory.deploy(); // Stop here! wait our contract to deploy
await contract.deployTransaction.wait(1);
const currentFavoriteNumber = await contract.retrieve();
console.log(`Current Favorite Number: ${currentFavoriteNumber.toString()}`);
const transactionResponse = await contract.store("7");
const transactionReceipt = await transactionResponse.wait(1);
const updatedFavoriteNumber = contract.retrieve();
console.log(`Updated Favorite number is: ${updatedFavoriteNumber}`);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); Part of video: https://youtu.be/gyMwXuJrbJQ?t=27204 This is what I'm getting:
What am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
othaime-en
Aug 6, 2022
Replies: 1 comment
-
add |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
eli5mecoding
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add
await
when declaringupdatedFavoriteNumber
:It should be
const updatedFavoriteNumber = await contract.retrieve()