Giter VIP home page Giter VIP logo

Comments (4)

XuNeal avatar XuNeal commented on May 24, 2024

ERC 20交易签名方式和普通签名没区别,只是toAddress代币的id,而实际的接收人是放在data中。详细的可以参见:https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md

或者你可以直接在构造签名时按照下面形式构造value, data,和toAddress字段

value: 0 // 0eth
data: `0xa9059cbb${padLeft(stripHexPrefix(realToAddress), 64)}${padLeft(value, 64)}`
to: tokenContractAddress

from token-core-ios.

MFJun avatar MFJun commented on May 24, 2024

👌

from token-core-ios.

Li-Qun avatar Li-Qun commented on May 24, 2024

@MFJun @XuNeal

请问这个 代币的data 是怎么拼接的,举例子中,0xa9059cbb${padLeft(stripHexPrefix(realToAddress), 64)}${padLeft(value, 64)}我不理解 “0xa9059cbb 是什么 和 用 $ 分隔的逻辑”,能写一个代币签名的测试用例吗,十分感谢,研究好久了还没解决这个代币问题

from token-core-ios.

XuNeal avatar XuNeal commented on May 24, 2024

@Li-Qun 0xa9059cbb是Ethereum的转账指令函数编码,可以认为是个固定值。用$号不是分割符是JS中的String Literals,上面代码相当于Swift中的"0xa9059cbb\(padLeft(stripHexPrefix(realToAddress), 64))\(padLeft(value, 64))"

from token-core-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.