Skip to content

Instantly share code, notes, and snippets.

View tranvictor's full-sized avatar

Victor Tran tranvictor

View GitHub Profile
{
"tokens": {
"OMG": {
"name": "OmiseGO",
"decimals": 18,
"address": "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07",
"minimalRecordResolution": "1000000000000000",
"maxPerBlockImbalance": "439794468212403470336",
"maxTotalImbalance": "722362414038872621056",
"internal use": true,
{
"tokens": {
"OMG": {
"name": "OmiseGO",
"decimals": 18,
"address": "0x5b9a857e0C3F2acc5b94f6693536d3Adf5D6e6Be",
"minimalRecordResolution": "1000000000000000",
"maxPerBlockImbalance": "775091297865175138304",
"maxTotalImbalance": "1096640332676811325440"
},
{
"tokens": {
"OMG": {
"name": "OmiseGO",
"decimals": 18,
"address": "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07",
"minimalRecordResolution": "1000000000000000",
"maxPerBlockImbalance": "775091297865175138304",
"maxTotalImbalance": "1096640332676811325440",
"internal use": true,
{
"tokens": {
"OMG": {
"name": "OmiseGO",
"decimals": 18,
"address": "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07",
"minimalRecordResolution": "1000000000000000",
"maxPerBlockImbalance": "775091297865175138304",
"maxTotalImbalance": "1096640332676811325440",
"internal use": true,
func (self IEOSigner) IEOSign(contributor ethereum.Address, userid uint64, ieoid *big.Int) (string, string, string, error) {
// 1. concat all bytes of contributor, userid (0 padded to 32 bytes), ieoid (0 padded to 32 bytes)
contributorBytes := ethereum.LeftPadBytes(contributor.Big().Bytes(), 20)
useridBytes := ethereum.LeftPadBytes(big.NewInt(int64(userid)).Bytes(), 32)
ieoidBytes := ethereum.LeftPadBytes(ieoid.Bytes(), 32)
concat := append(contributorBytes, useridBytes...)
concat = append(concat, ieoidBytes...)
// 2. sha3 the concatenation to get msg
msg := crypto.Keccak256(concat)
fmt.Printf("msg: %s\n", ethereum.ToHex(msg))
{
"tokens": {
"OMG": {
"name": "OmiseGO",
"decimals": 18,
"address": "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07",
"minimalRecordResolution": "1000000000000000",
"maxPerBlockImbalance": "439794468212403470336",
"maxTotalImbalance": "722362414038872621056",
"internal use": true,
{
"tokens": {
"OMG": {
"name": "OmiseGO",
"decimals": 18,
"address": "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07",
"minimalRecordResolution": "1000000000000000",
"maxPerBlockImbalance": "775091297865175138304",
"maxTotalImbalance": "1096640332676811325440",
"internal use": true,
{
"tokens": {
"OMG": {
"name": "OmiseGO",
"decimals": 18,
"address": "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07",
"minimalRecordResolution": "1000000000000000",
"maxPerBlockImbalance": "775091297865175138304",
"maxTotalImbalance": "1096640332676811325440",
"internal use": true,
{
"tokens": {
"OMG": {
"name": "OmiseGO",
"decimals": 18,
"address": "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07",
"minimalRecordResolution": "1000000000000000",
"maxPerBlockImbalance": "775091297865175138304",
"maxTotalImbalance": "1096640332676811325440",
"internal use": true,
{
"tokens": {
"OMG": {
"name": "OmiseGO",
"decimals": 18,
"address": "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07",
"minimalRecordResolution": "1000000000000000",
"maxPerBlockImbalance": "775091297865175138304",
"maxTotalImbalance": "1096640332676811325440",
"internal use": true,