synchronous [solidity]
asynchronous [javascriptl
cooking
Synchronous
- Put popcorn in microwave
- Wait for popcorn to finish
- Pour drinks for everyone
Asynchronous
- Put popcorn in the mircrowave
- Pour drinks for everyone
- Wait for popcorn to finish
Promise -Pending -Fulfilled -Rejected
- we always use async function for deploying our solidity code
async function main() {}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
to compile our solidity code in js we use solcjs
to add yarn we type corepack enable
;
- The ethers.js library aims to be a complete and compact library for interacting with the Ethereum Blockchain and its ecosystem.
- we can encrypt our private key and store locally
-steps to encrypt key
- we create file
encryptKey.js
- crearte a function to encrypt our private adress
require("dotenv").config();
const ethers = require("ethers");
const fs = require("fs");
async function main() {
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY);
const encryptedJsonKey = await wallet.encrypt(
process.env.PRIVATE_KEY_PASSWORD
);
console.log(encryptedJsonKey);
// we store a encrypted password and we pass pass password while we run the code
fs.writeFileSync("./encryptedJsonKey.json", encryptedJsonKey);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});