Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V6创建interface语法有变;删掉不必要代码L70 #175

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 23_Frontrun/frontrun.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const contractAddress = '0xC76A71C4492c11bbaDC841342C4Cb470b5d12193'
const contractFM = new ethers.Contract(contractAddress, contractABI, provider)

//3.创建Interface对象,用于检索mint函数。
//V6 版本 const iface = new ethers.Interface(contractABI)
const iface = new ethers.utils.Interface(contractABI)
function getSignature(fn) {
// V6 版本 return iface.getFunction("mint").selector
Expand Down Expand Up @@ -67,7 +68,7 @@ const frontRun = async () => {
console.log(`frontrun 交易成功,交易hash是:${receipt.transactionHash}`)
console.log(`铸造发起的地址是:${tx.from}`)
console.log(`编号${aimTokenId}NFT的持有者是${await contractFM.ownerOf(aimTokenId)}`)//刚刚mint的nft持有者并不是tx.from
console.log(`编号${aimTokenId.add(1)}的NFT的持有者是:${await contractFM.ownerOf(aimTokenId.add(1))}`)//tx.from被wallet.address抢跑,mint了下一个nft

console.log(`铸造发起的地址是不是对应NFT的持有者:${tx.from === await contractFM.ownerOf(aimTokenId)}`)//比对地址,tx.from被抢跑
//检验区块内数据结果
const block = await provider.getBlock(tx.blockNumber)
Expand Down