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

18_Signature: 提供报错的解决方案 #171

Open
wants to merge 1 commit 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
11 changes: 11 additions & 0 deletions 18_Signature/Signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
// -> 调用合约的mint()函数进行铸造

import { ethers } from "ethers";
// 这里的 contract.json 是已经 link 好的 bytecode
// 如果使用 WTF-solidity 37 中 Signature.sol 由 foundry 或 remix 编译出的 json 文件
// 由于 lib 中带有 可见性为 public 的函数, 直接用这里的 json 会报 invalid BytesLike value
//
// 解决办法1:
// 先部署 ECDSA 合约, 把 bytecode 中的占位符换成 ECDSA 合约的地址(无0x前缀)
// 占位符形如 __$e56fc32e79819d3ff5a3cf88541a8407cd$__
// 见 https://docs.soliditylang.org/en/latest/using-the-compiler.html#library-linking
//
// 解决办法2:
// 把 lib 中的 public/external 函数全部换成 internal, 再编译一遍, 就可以直接用编译出的 bytecode 了
import * as contractJson from "./contract.json" assert {type: "json"};

// 1. 创建provider和wallet
Expand Down