eth-erc721

ERC-721 'NFT' token interface with example developer badge token contract
Log | Files | Refs | LICENSE

commit 96ee30fe26b6dc53097ef813add49d5b89e85f30
parent ad8fcce0e992f9292bb3d65b8ae038d4b7db98d5
Author: nolash <dev@holbrook.no>
Date:   Mon, 10 May 2021 09:15:39 +0200

Rename package

Diffstat:
Apython/eth_badgetoken/__init__.py | 1+
Apython/eth_badgetoken/data/BadgeToken.bin | 2++
Apython/eth_badgetoken/data/BadgeToken.json | 1+
Apython/eth_badgetoken/runnable/deploy.py | 130+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apython/eth_badgetoken/runnable/mint.py | 132+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apython/eth_badgetoken/token.py | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msolidity/BadgeToken.sol | 33+++++++++++++++++++--------------
7 files changed, 384 insertions(+), 14 deletions(-)

diff --git a/python/eth_badgetoken/__init__.py b/python/eth_badgetoken/__init__.py @@ -0,0 +1 @@ +from .token import BadgeToken diff --git a/python/eth_badgetoken/data/BadgeToken.bin b/python/eth_badgetoken/data/BadgeToken.bin @@ -0,0 +1 @@ +60806040523480156200001157600080fd5b50604051620032963803806200329683398181016040528101906200003791906200022c565b82600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600b9080519060200190620000d0929190620000f3565b5080600c9080519060200190620000e9929190620000f3565b5050505062000472565b82805462000101906200037d565b90600052602060002090601f01602090048101928262000125576000855562000171565b82601f106200014057805160ff191683800117855562000171565b8280016001018555821562000171579182015b828111156200017057825182559160200191906001019062000153565b5b50905062000180919062000184565b5090565b5b808211156200019f57600081600090555060010162000185565b5090565b6000620001ba620001b484620002dd565b620002b4565b905082815260208101848484011115620001d357600080fd5b620001e084828562000347565b509392505050565b600081519050620001f98162000458565b92915050565b600082601f8301126200021157600080fd5b815162000223848260208601620001a3565b91505092915050565b6000806000606084860312156200024257600080fd5b60006200025286828701620001e8565b935050602084015167ffffffffffffffff8111156200027057600080fd5b6200027e86828701620001ff565b925050604084015167ffffffffffffffff8111156200029c57600080fd5b620002aa86828701620001ff565b9150509250925092565b6000620002c0620002d3565b9050620002ce8282620003b3565b919050565b6000604051905090565b600067ffffffffffffffff821115620002fb57620002fa62000418565b5b620003068262000447565b9050602081019050919050565b6000620003208262000327565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60005b83811015620003675780820151818401526020810190506200034a565b8381111562000377576000848401525b50505050565b600060028204905060018216806200039657607f821691505b60208210811415620003ad57620003ac620003e9565b5b50919050565b620003be8262000447565b810181811067ffffffffffffffff82111715620003e057620003df62000418565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b620004638162000313565b81146200046f57600080fd5b50565b612e1480620004826000396000f3fe608060405260043610610152576000357c01000000000000000000000000000000000000000000000000000000009004806370a08231116100c8578063b88d4fde1161008c578063b88d4fde14610456578063c87b56dd14610472578063c9796c39146104af578063e985e9c5146104ec578063f1b0aa1514610529578063f2fde38b1461056657610152565b806370a082311461036f5780638da5cb5b146103ac57806392088cf6146103d757806395d89b4114610402578063a22cb4651461042d57610152565b806323b872dd1161011a57806323b872dd146102435780632f745c591461025f57806342842e0e1461029c578063449a52f8146102b85780634f6ccce7146102f55780636352211e1461033257610152565b806301ffc9a71461015757806306fdde0314610194578063081812fc146101bf578063095ea7b3146101fc57806318160ddd14610218575b600080fd5b34801561016357600080fd5b5061017e60048036038101906101799190612842565b6105a3565b60405161018b9190612924565b60405180910390f35b3480156101a057600080fd5b506101a96107a1565b6040516101b6919061295a565b60405180910390f35b3480156101cb57600080fd5b506101e660048036038101906101e1919061286b565b61082f565b6040516101f39190612909565b60405180910390f35b610216600480360381019061021191906127dd565b61086c565b005b34801561022457600080fd5b5061022d610988565b60405161023a919061297c565b60405180910390f35b61025d600480360381019061025891906126d7565b610995565b005b34801561026b57600080fd5b50610286600480360381019061028191906127dd565b610a04565b604051610293919061297c565b60405180910390f35b6102b660048036038101906102b191906126d7565b610adb565b005b3480156102c457600080fd5b506102df60048036038101906102da91906127dd565b610b4a565b6040516102ec9190612924565b60405180910390f35b34801561030157600080fd5b5061031c6004803603810190610317919061286b565b610e24565b604051610329919061297c565b60405180910390f35b34801561033e57600080fd5b506103596004803603810190610354919061286b565b610e72565b6040516103669190612909565b60405180910390f35b34801561037b57600080fd5b5061039660048036038101906103919190612672565b610eaf565b6040516103a3919061297c565b60405180910390f35b3480156103b857600080fd5b506103c1610ef8565b6040516103ce9190612909565b60405180910390f35b3480156103e357600080fd5b506103ec610f1c565b6040516103f99190612909565b60405180910390f35b34801561040e57600080fd5b50610417610f42565b604051610424919061295a565b60405180910390f35b34801561043957600080fd5b50610454600480360381019061044f91906127a1565b610fd0565b005b610470600480360381019061046b9190612726565b611273565b005b34801561047e57600080fd5b506104996004803603810190610494919061286b565b6113bd565b6040516104a6919061295a565b60405180910390f35b3480156104bb57600080fd5b506104d660048036038101906104d19190612819565b611429565b6040516104e3919061295a565b60405180910390f35b3480156104f857600080fd5b50610513600480360381019061050e919061269b565b611c58565b6040516105209190612924565b60405180910390f35b34801561053557600080fd5b50610550600480360381019061054b919061286b565b611cf0565b60405161055d919061297c565b60405180910390f35b34801561057257600080fd5b5061058d60048036038101906105889190612672565b611d56565b60405161059a9190612924565b60405180910390f35b60006380ac58cd7c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156105f8576001905061079c565b635b5e139f7c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561064b576001905061079c565b63780e9d637c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561069e576001905061079c565b63449a52f87c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156106f1576001905061079c565b63f1b0aa157c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610744576001905061079c565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610797576001905061079c565b600090505b919050565b600b80546107ae90612bc1565b80601f01602080910402602001604051908101604052809291908181526020018280546107da90612bc1565b80156108275780601f106107fc57610100808354040283529160200191610827565b820191906000526020600020905b81548152906001019060200180831161080a57829003601f168201915b505050505081565b60006008600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b3373ffffffffffffffffffffffffffffffffffffffff166004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146108d757600080fd5b816008600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000600180549050905090565b60606109a384848484611f7c565b818373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a450505050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548210610a5157600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110610ac8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154905092915050565b6060610ae984848484611f7c565b818373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a450505050565b60003373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ba457600080fd5b600060036000848152602001908152602001600020541480610bcb57506000600180549050145b610bd457600080fd5b600080600180549050915083905060018190806001815401808255809150506001900390600052602060002001600090919091909150558160036000838152602001908152602001600020819055506002439080600181540180825580915050600190039060005260206000200160009091909190915055846004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508360066000600560008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050815260200190815260200160002081905550600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020849080600181540180825580915050600190039060005260206000200160009091909190915055600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610dae90612c24565b91905055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f886604051610e10919061297c565b60405180910390a360019250505092915050565b600060018281548110610e60577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b60006004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600c8054610f4f90612bc1565b80601f0160208091040260200160405190810160405280929190818152602001828054610f7b90612bc1565b8015610fc85780601f10610f9d57610100808354040283529160200191610fc8565b820191906000526020600020905b815481529060010190602001808311610fab57829003601f168201915b505050505081565b80156110f157600073ffffffffffffffffffffffffffffffffffffffff16600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461106e57600080fd5b81600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061120a565b600073ffffffffffffffffffffffffffffffffffffffff16600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561118a57600080fd5b6000600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b8173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516112679190612924565b60405180910390a35050565b61127f84848484611f7c565b818373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4818373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f75c9e114f073c346aac7d1d7e9a3c3c14edabcdd27de07d1d9e425f45d318c5e600a60008781526020019081526020016000206001600a6000898152602001908152602001600020805490506113609190612a96565b81548110611397577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001546040516113af919061293f565b60405180910390a450505050565b6060611422600160036000858152602001908152602001600020548154811061140f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154600102611429565b9050919050565b606080600080604767ffffffffffffffff811115611470577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156114a25781602001600182028036833780820191505090505b5092507f730000000000000000000000000000000000000000000000000000000000000083600081518110611500577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f68000000000000000000000000000000000000000000000000000000000000008360018151811061158a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f610000000000000000000000000000000000000000000000000000000000000083600281518110611614577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f32000000000000000000000000000000000000000000000000000000000000008360038151811061169e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f350000000000000000000000000000000000000000000000000000000000000083600481518110611728577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f3600000000000000000000000000000000000000000000000000000000000000836005815181106117b2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f3a000000000000000000000000000000000000000000000000000000000000008360068151811061183c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506007905060005b6020811015611c4c57600460f08783602081106118b8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b1a7f0100000000000000000000000000000000000000000000000000000000000000027f010000000000000000000000000000000000000000000000000000000000000090041660ff16908060020a82049150509250600a8360ff1610156119b6576030836119279190612a5f565b7f010000000000000000000000000000000000000000000000000000000000000002848381518110611982577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350611a4e565b6057836119c39190612a5f565b7f010000000000000000000000000000000000000000000000000000000000000002848381518110611a1e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053505b600f868260208110611a89577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b1a7f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004169250600a8360ff161015611b8657603083611aeb9190612a5f565b7f01000000000000000000000000000000000000000000000000000000000000000284600184611b1b9190612a09565b81518110611b52577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350611c2a565b605783611b939190612a5f565b7f01000000000000000000000000000000000000000000000000000000000000000284600184611bc39190612a09565b81518110611bfa577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053505b600282611c379190612a09565b91508080611c4490612c24565b915050611872565b50829350505050919050565b60008173ffffffffffffffffffffffffffffffffffffffff16600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614905092915050565b6000806003600084815260200190815260200160002054905060028181548110611d43577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154915050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611db157600080fd5b60606000606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff169150600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805480602002602001604051908101604052809291908181526020018280548015611e6357602002820191906000526020600020905b815481526020019060010190808311611e4f575b5050505050905060005b8151811015611ed557611ec28387848481518110611eb4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015187611f7c565b8080611ecd90612c24565b915050611e6d565b50846000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360019350505050919050565b60006004600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508473ffffffffffffffffffffffffffffffffffffffff166004600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461201f57600080fd5b3373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614612153573373ffffffffffffffffffffffffffffffffffffffff166008600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061214957503373ffffffffffffffffffffffffffffffffffffffff16600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b61215257600080fd5b5b60006008600085815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490506122349190612a96565b8154811061226b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600660008681526020019081526020016000205481548110612300577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061235e90612b97565b9190505550600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020839080600181540180825580915050600190039060005260206000200160009091909190915055600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061241990612c24565b9190505550836004600085815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060005b8251811015612599578281815181106124b5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916600a60008681526020019081526020016000206020836125419190612c6d565b81548110612578577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550808061259190612c24565b915050612473565b505050505050565b60006125b46125af846129bc565b612997565b9050828152602081018484840111156125cc57600080fd5b6125d7848285612b55565b509392505050565b6000813590506125ee81612d6b565b92915050565b60008135905061260381612d82565b92915050565b60008135905061261881612d99565b92915050565b60008135905061262d81612db0565b92915050565b600082601f83011261264457600080fd5b81356126548482602086016125a1565b91505092915050565b60008135905061266c81612dc7565b92915050565b60006020828403121561268457600080fd5b6000612692848285016125df565b91505092915050565b600080604083850312156126ae57600080fd5b60006126bc858286016125df565b92505060206126cd858286016125df565b9150509250929050565b6000806000606084860312156126ec57600080fd5b60006126fa868287016125df565b935050602061270b868287016125df565b925050604061271c8682870161265d565b9150509250925092565b6000806000806080858703121561273c57600080fd5b600061274a878288016125df565b945050602061275b878288016125df565b935050604061276c8782880161265d565b925050606085013567ffffffffffffffff81111561278957600080fd5b61279587828801612633565b91505092959194509250565b600080604083850312156127b457600080fd5b60006127c2858286016125df565b92505060206127d3858286016125f4565b9150509250929050565b600080604083850312156127f057600080fd5b60006127fe858286016125df565b925050602061280f8582860161265d565b9150509250929050565b60006020828403121561282b57600080fd5b600061283984828501612609565b91505092915050565b60006020828403121561285457600080fd5b60006128628482850161261e565b91505092915050565b60006020828403121561287d57600080fd5b600061288b8482850161265d565b91505092915050565b61289d81612aca565b82525050565b6128ac81612adc565b82525050565b6128bb81612ae8565b82525050565b60006128cc826129ed565b6128d681856129f8565b93506128e6818560208601612b64565b6128ef81612d5a565b840191505092915050565b61290381612b3e565b82525050565b600060208201905061291e6000830184612894565b92915050565b600060208201905061293960008301846128a3565b92915050565b600060208201905061295460008301846128b2565b92915050565b6000602082019050818103600083015261297481846128c1565b905092915050565b600060208201905061299160008301846128fa565b92915050565b60006129a16129b2565b90506129ad8282612bf3565b919050565b6000604051905090565b600067ffffffffffffffff8211156129d7576129d6612d2b565b5b6129e082612d5a565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b6000612a1482612b3e565b9150612a1f83612b3e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612a5457612a53612c9e565b5b828201905092915050565b6000612a6a82612b48565b9150612a7583612b48565b92508260ff03821115612a8b57612a8a612c9e565b5b828201905092915050565b6000612aa182612b3e565b9150612aac83612b3e565b925082821015612abf57612abe612c9e565b5b828203905092915050565b6000612ad582612b1e565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015612b82578082015181840152602081019050612b67565b83811115612b91576000848401525b50505050565b6000612ba282612b3e565b91506000821415612bb657612bb5612c9e565b5b600182039050919050565b60006002820490506001821680612bd957607f821691505b60208210811415612bed57612bec612cfc565b5b50919050565b612bfc82612d5a565b810181811067ffffffffffffffff82111715612c1b57612c1a612d2b565b5b80604052505050565b6000612c2f82612b3e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612c6257612c61612c9e565b5b600182019050919050565b6000612c7882612b3e565b9150612c8383612b3e565b925082612c9357612c92612ccd565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b612d7481612aca565b8114612d7f57600080fd5b50565b612d8b81612adc565b8114612d9657600080fd5b50565b612da281612ae8565b8114612dad57600080fd5b50565b612db981612af2565b8114612dc457600080fd5b50565b612dd081612b3e565b8114612ddb57600080fd5b5056fea2646970667358221220e36021cf090ccd1c0b566add7a32411adad2f4ac59b97c5ebadbb9821e31623064736f6c63430008030033 +\ No newline at end of file diff --git a/python/eth_badgetoken/data/BadgeToken.json b/python/eth_badgetoken/data/BadgeToken.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_operator","type":"address"},{"indexed":false,"internalType":"bool","name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_minter","type":"address"},{"indexed":true,"internalType":"address","name":"_beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"_data","type":"bytes32"}],"name":"TransferWithData","type":"event"},{"inputs":[{"internalType":"address","name":"_approved","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"declarator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"mintTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"mintedAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"bool","name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_data","type":"bytes32"}],"name":"toURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/python/eth_badgetoken/runnable/deploy.py b/python/eth_badgetoken/runnable/deploy.py @@ -0,0 +1,130 @@ +"""Deploys badge NFT + +.. moduleauthor:: Louis Holbrook <dev@holbrook.no> +.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 + +""" + +# SPDX-License-Identifier: GPL-3.0-or-later + +# standard imports +import sys +import os +import json +import argparse +import logging +import time +from enum import Enum + +# external imports +from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer +from crypto_dev_signer.keystore.dict import DictKeystore +from chainlib.chain import ChainSpec +from chainlib.eth.nonce import ( + RPCNonceOracle, + OverrideNonceOracle, + ) +from chainlib.eth.gas import ( + RPCGasOracle, + OverrideGasOracle, + ) +from chainlib.eth.connection import EthHTTPConnection +from chainlib.eth.tx import receipt +from chainlib.eth.constant import ZERO_ADDRESS + +# local imports +from eth_badgetoken import BadgeToken + +logging.basicConfig(level=logging.WARNING) +logg = logging.getLogger() + +script_dir = os.path.dirname(__file__) +data_dir = os.path.join(script_dir, '..', 'data') + + +argparser = argparse.ArgumentParser() +argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='Web3 provider url (http only)') +argparser.add_argument('-w', action='store_true', help='Wait for the last transaction to be confirmed') +argparser.add_argument('-ww', action='store_true', help='Wait for every transaction to be confirmed') +argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string') +argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing') +argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration') +argparser.add_argument('--name', default='Giftable Token', type=str, help='Token name') +argparser.add_argument('--symbol', default='GFT', type=str, help='Token symbol') +argparser.add_argument('--declarator-address', dest='declarator_address', type=str, default=ZERO_ADDRESS, help='Token decimals') +argparser.add_argument('-d', action='store_true', help='Dump RPC calls to terminal and do not send') +argparser.add_argument('--gas-price', type=int, dest='gas_price', help='Override gas price') +argparser.add_argument('--nonce', type=int, help='Override transaction nonce') +argparser.add_argument('-v', action='store_true', help='Be verbose') +argparser.add_argument('-vv', action='store_true', help='Be more verbose') +args = argparser.parse_args() + +if args.vv: + logg.setLevel(logging.DEBUG) +elif args.v: + logg.setLevel(logging.INFO) + +block_all = args.ww +block_last = args.w or block_all + +passphrase_env = 'ETH_PASSPHRASE' +if args.env_prefix != None: + passphrase_env = args.env_prefix + '_' + passphrase_env +passphrase = os.environ.get(passphrase_env) +if passphrase == None: + logg.warning('no passphrase given') + passphrase='' + +signer_address = None +keystore = DictKeystore() +if args.y != None: + logg.debug('loading keystore file {}'.format(args.y)) + signer_address = keystore.import_keystore_file(args.y, password=passphrase) + logg.debug('now have key for signer address {}'.format(signer_address)) +signer = EIP155Signer(keystore) + +chain_spec = ChainSpec.from_chain_str(args.i) + +rpc = EthHTTPConnection(args.p) +nonce_oracle = None +if args.nonce != None: + nonce_oracle = OverrideNonceOracle(signer_address, args.nonce) +else: + nonce_oracle = RPCNonceOracle(signer_address, rpc) + +gas_oracle = None +if args.gas_price !=None: + gas_oracle = OverrideGasOracle(price=args.gas_price, conn=rpc, code_callback=BadgeToken.gas) +else: + gas_oracle = RPCGasOracle(rpc, code_callback=BadgeToken.gas) + +dummy = args.d + +token_name = args.name +token_symbol = args.symbol +token_declarator = args.declarator_address + + +def main(): + c = BadgeToken(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.constructor(signer_address, token_declarator, token_name, token_symbol) + if dummy: + print(tx_hash_hex) + print(o) + else: + rpc.do(o) + if block_last: + r = rpc.wait(tx_hash_hex) + if r['status'] == 0: + sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you') + sys.exit(1) + # TODO: pass through translator for keys (evm tester uses underscore instead of camelcase) + address = r['contractAddress'] + + print(address) + else: + print(tx_hash_hex) + + +if __name__ == '__main__': + main() diff --git a/python/eth_badgetoken/runnable/mint.py b/python/eth_badgetoken/runnable/mint.py @@ -0,0 +1,132 @@ +"""Mints and gifts NFTs to a given address + +.. moduleauthor:: Louis Holbrook <dev@holbrook.no> +.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 + +""" + +# SPDX-License-Identifier: GPL-3.0-or-later + +# standard imports +import sys +import os +import json +import argparse +import logging +import time + +# third-party imports +from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer +from crypto_dev_signer.keystore.dict import DictKeystore +from chainlib.eth.tx import receipt +from chainlib.chain import ChainSpec +from chainlib.eth.nonce import ( + RPCNonceOracle, + OverrideNonceOracle, + ) +from chainlib.eth.gas import ( + RPCGasOracle, + OverrideGasOracle, + ) +from chainlib.eth.connection import EthHTTPConnection +from hexathon import strip_0x + +# local imports +from eth_badgetoken import BadgeToken + +logging.basicConfig(level=logging.WARNING) +logg = logging.getLogger() + +script_dir = os.path.dirname(__file__) +data_dir = os.path.join(script_dir, '..', 'data') + +argparser = argparse.ArgumentParser() +argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='Web3 provider url (http only)') +argparser.add_argument('-e', action='store_true', help='Treat all transactions as essential') +argparser.add_argument('-w', action='store_true', help='Wait for the last transaction to be confirmed') +argparser.add_argument('-ww', action='store_true', help='Wait for every transaction to be confirmed') +argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string') +argparser.add_argument('-a', '--token-address', required='True', dest='a', type=str, help='Giftable token address') +argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing') +argparser.add_argument('-v', action='store_true', help='Be verbose') +argparser.add_argument('-vv', action='store_true', help='Be more verbose') +argparser.add_argument('-d', action='store_true', help='Dump RPC calls to terminal and do not send') +argparser.add_argument('--gas-price', type=int, dest='gas_price', help='Override gas price') +argparser.add_argument('--nonce', type=int, help='Override transaction nonce') +argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration') +argparser.add_argument('--recipient', type=str, help='Recipient account address. If not set, tokens will be gifted to the keystore account') +argparser.add_argument('token_id', type=str, help='32 bytes digest to use as token id') +args = argparser.parse_args() + +if args.vv: + logg.setLevel(logging.DEBUG) +elif args.v: + logg.setLevel(logging.INFO) + +block_all = args.ww +block_last = args.w or block_all + +passphrase_env = 'ETH_PASSPHRASE' +if args.env_prefix != None: + passphrase_env = args.env_prefix + '_' + passphrase_env +passphrase = os.environ.get(passphrase_env) +if passphrase == None: + logg.warning('no passphrase given') + passphrase='' + +signer_address = None +keystore = DictKeystore() +if args.y != None: + logg.debug('loading keystore file {}'.format(args.y)) + signer_address = keystore.import_keystore_file(args.y, password=passphrase) + logg.debug('now have key for signer address {}'.format(signer_address)) +signer = EIP155Signer(keystore) + +chain_spec = ChainSpec.from_chain_str(args.i) + +rpc = EthHTTPConnection(args.p) +nonce_oracle = None +if args.nonce != None: + nonce_oracle = OverrideNonceOracle(signer_address, args.nonce) +else: + nonce_oracle = RPCNonceOracle(signer_address, rpc) + +gas_oracle = None +if args.gas_price !=None: + gas_oracle = OverrideGasOracle(price=args.gas_price, conn=rpc, code_callback=BadgeToken.gas) +else: + gas_oracle = RPCGasOracle(rpc, code_callback=BadgeToken.gas) + +dummy = args.d + +token_address = args.a +recipient_address = args.recipient +if recipient_address == None: + recipient_address = signer_address +token_bytes = bytes.fromhex(strip_0x(args.token_id)) +if len(token_bytes) != 32: + raise ValueError('token_id must be a 32 byte hex string') + +token_id = int.from_bytes(token_bytes, byteorder='big') + +def main(): + c = BadgeToken(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.mint_to(token_address, signer_address, recipient_address, token_id) + if dummy: + print(tx_hash_hex) + print(o) + else: + rpc.do(o) + if block_last: + r = rpc.wait(tx_hash_hex) + if r['status'] == 0: + sys.stderr.write('EVM revert. Wish I had more to tell you') + sys.exit(1) + + logg.info('mint to {} tx {}'.format(recipient_address, tx_hash_hex)) + + print(tx_hash_hex) + + +if __name__ == '__main__': + main() diff --git a/python/eth_badgetoken/token.py b/python/eth_badgetoken/token.py @@ -0,0 +1,99 @@ +# standard imports +import os + +# external imports +from chainlib.eth.tx import ( + TxFormat, + TxFactory, + ) +from chainlib.eth.contract import ( + ABIContractEncoder, + ABIContractType, + abi_decode_single, + ) +from chainlib.jsonrpc import jsonrpc_template +from chainlib.eth.constant import ZERO_ADDRESS +from hexathon import ( + add_0x, + ) + +# local imports +from eth_erc721 import ERC721 + +moddir = os.path.dirname(__file__) +datadir = os.path.join(moddir, 'data') + + +class BadgeToken(ERC721): + + __abi = None + __bytecode = None + + @staticmethod + def abi(): + if BadgeToken.__abi == None: + f = open(os.path.join(datadir, 'BadgeToken.json'), 'r') + BadgeToken.__abi = json.load(f) + f.close() + return BadgeToken.__abi + + + @staticmethod + def bytecode(): + if BadgeToken.__bytecode == None: + f = open(os.path.join(datadir, 'BadgeToken.bin')) + BadgeToken.__bytecode = f.read() + f.close() + return BadgeToken.__bytecode + + + @staticmethod + def gas(code=None): + return 3500000 + + + def constructor(self, sender_address, declarator, name, symbol, tx_format=TxFormat.JSONRPC): + code = BadgeToken.bytecode() + enc = ABIContractEncoder() + enc.address(declarator) + enc.string(name) + enc.string(symbol) + code += enc.get() + tx = self.template(sender_address, None, use_nonce=True) + tx = self.set_code(tx, code) + return self.finalize(tx, tx_format) + + + def mint_to(self, contract_address, sender_address, address, token_id, tx_format=TxFormat.JSONRPC): + enc = ABIContractEncoder() + enc.method('mintTo') + enc.typ(ABIContractType.ADDRESS) + enc.typ(ABIContractType.UINT256) + enc.address(address) + enc.uint256(token_id) + data = enc.get() + tx = self.template(sender_address, contract_address, use_nonce=True) + tx = self.set_code(tx, data) + tx = self.finalize(tx, tx_format) + return tx + + + + def minted_at(self, contract_address, token_id, sender_address=ZERO_ADDRESS): + o = jsonrpc_template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('mintedAt') + enc.typ(ABIContractType.UINT256) + enc.uint256(token_id) + data = add_0x(enc.get()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + o['params'].append('latest') + return o + + + @classmethod + def parse_minted_at(self, v): + return abi_decode_single(ABIContractType.UINT256, v) diff --git a/solidity/BadgeToken.sol b/solidity/BadgeToken.sol @@ -1,26 +1,25 @@ pragma solidity ^0.8.0; +// SPDX-License-Identifier: GPL-3.0-or-later + contract BadgeToken { // EIP 173 address public owner; - // Points to Declarator implementer - address public declarator; - - uint256[] token; - uint256[] tokenMintedAt; + uint256[] token; // token item registry + uint256[] tokenMintedAt; // block height mapping to token array - mapping(uint256 => uint256) tokenIndex; // tokenId uint256 -> position in token array uint256 - mapping(uint256 => address) tokenOwner; // tokenId uint256 -> owner address - mapping(address => uint256[]) tokenOwnerIndex; // owner address -> tokenId uint256 - mapping(uint256 => uint256) tokenOwnerIdIndex; // - mapping(address => uint256) tokenOwnerCursor; + mapping(uint256 => uint256) tokenIndex; // tokenId to token array index + mapping(uint256 => address) tokenOwner; // tokenId to owner address + mapping(address => uint256[]) tokenOwnerIndex; // index of owned tokens by owner address + mapping(uint256 => uint256) tokenOwnerIdIndex; // index of owned token ids in tokenOwnerIndex + mapping(address => uint256) tokenOwnerCursor; // end of token owner index array - mapping(uint256 => address) tokenAllowance; - mapping(address => address) tokenOperator; + mapping(uint256 => address) tokenAllowance; // backend for approve + mapping(address => address) tokenOperator; // backend for setApprovalForAll - mapping(uint256 => bytes32[]) tokenData; // tokenId uint256 -> tokenData bytes32 + mapping(uint256 => bytes32[]) tokenData; // store optional data submitted with safeTransferFrom // ERC-721 (Metadata - optional) string public name; @@ -28,6 +27,8 @@ contract BadgeToken { // ERC-721 (Metadata - optional) string public symbol; + address public declarator; // Points to Declarator implementer + // ERC-721 event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); // ERC-721 @@ -61,6 +62,7 @@ contract BadgeToken { return tokenOwner[_tokenId]; } + // shared function for transfer methods function transferCore(address _from, address _to, uint256 _tokenId, bytes memory _data) internal { address currentTokenOwner; @@ -156,7 +158,7 @@ contract BadgeToken { return tokenOwnerIndex[_owner][_index]; } - // TODO: move to library function? + // create sha256 scheme URI from tokenId function toURI(bytes32 _data) public pure returns(string memory) { bytes memory out; uint8 t; @@ -264,6 +266,9 @@ contract BadgeToken { if (interfaceID == 0x449a52f8) { // Minter return true; } + if (interfaceID == 0xf1b0aa15) { // FungibleMinter + return true; + } if (interfaceID == 0x01ffc9a7) { // EIP 165 return true; }