
【科学家养成日记#8】生成消息签名,提交到API
很多项目为了让用户省点GAS,经常只需用户提交签名就能完成交易
比如你在Decentraland的市场挂单交易, 只需签名一下,就能挂单到市场
逻辑是,用你的私钥给一个信息加密生成一个签名,然后把这个信息提交到项目的API上
理解这个逻辑,就比较容易自动化这个过程。这次拿今天比较热门的一个NFT项目(Prime Ape Planet)白名单抽奖做个例子
逻辑是,新建一个钱包,然后给参与白名单抽奖的信息弄个签名,然后把签名提交到API上
代码:
1 | var Web3 = require('web3'); |
效果:
github:https://github.com/ericet/kexuejia/blob/master/primeApeWhitelist.js
自动化签名的应用场景还有很多,比如zapper的每日打卡,某项目的签名就领NFT,decentraland市场交易,等等
- Thanks for your appreciation. / 感谢您的赞赏
List of appreciation
Because of your support, I realize the value of writing articles. / 由于您的支持,我才能够实现写作的价值。
This piece of writing is an original article, utilizing theCC BY-NC-SA 4.0Agreement. For complete reproduction, please acknowledge the source as Courtesy ofERICET
Comment ()