-
Hi guys, I wondered, Why is the public key not necessary when we make contract? Code: let provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL)
let wallet = new ethers.Wallet(process.env.PRIVATE_KEY, 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() Here is the transaction receipt: (Ganache) {
to: null,
from: '0xf14BfEC2EE5f37bce3aD4F56C8491966c160Aa73',
......
} How does the transaction know my public key when I do not provide it? |
Beta Was this translation helpful? Give feedback.
Answered by
Finn66
Oct 8, 2022
Replies: 1 comment
-
Got it,Public key is generated by private key const keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey));
defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex"));
defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Finn66
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got it,Public key is generated by private key