eth-erc20

ERC20 interface and example giftable token contract
Log | Files | Refs | LICENSE

commit 04f9b5868b0ce7b08e2be9c8a725b4da1a78c455
parent d7fb3f232c2d51c692c1b25f61418938bdd775f1
Author: lash <dev@holbrook.no>
Date:   Wed, 22 Feb 2023 10:48:32 +0000

Add burn to giftable tokebs

Diffstat:
Mpython/giftable_erc20_token/data/GiftableToken.bin | 4++--
Mpython/giftable_erc20_token/data/GiftableToken.json | 2+-
Mpython/giftable_erc20_token/factory.py | 45+++++++++++++++++++++++++++++++++++++++++++++
Mpython/tests/test_giftable.py | 39+++++++++++++++++++++++++++++++++++++++
Msolidity/GiftableToken.bin | 4++--
Msolidity/GiftableToken.json | 2+-
Msolidity/GiftableToken.sol | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
7 files changed, 148 insertions(+), 16 deletions(-)

diff --git a/python/giftable_erc20_token/data/GiftableToken.bin b/python/giftable_erc20_token/data/GiftableToken.bin @@ -1 +1 @@ -60806040523480156200001157600080fd5b5060405162001e4538038062001e4583398181016040528101906200003791906200032a565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550836002908162000088919062000621565b5082600390816200009a919062000621565b5081600460006101000a81548160ff021916908360ff16021790555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550806008819055505050505062000708565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b62000187826200013c565b810181811067ffffffffffffffff82111715620001a957620001a86200014d565b5b80604052505050565b6000620001be6200011e565b9050620001cc82826200017c565b919050565b600067ffffffffffffffff821115620001ef57620001ee6200014d565b5b620001fa826200013c565b9050602081019050919050565b60005b83811015620002275780820151818401526020810190506200020a565b60008484015250505050565b60006200024a6200024484620001d1565b620001b2565b90508281526020810184848401111562000269576200026862000137565b5b6200027684828562000207565b509392505050565b600082601f83011262000296576200029562000132565b5b8151620002a884826020860162000233565b91505092915050565b600060ff82169050919050565b620002c981620002b1565b8114620002d557600080fd5b50565b600081519050620002e981620002be565b92915050565b6000819050919050565b6200030481620002ef565b81146200031057600080fd5b50565b6000815190506200032481620002f9565b92915050565b6000806000806080858703121562000347576200034662000128565b5b600085015167ffffffffffffffff8111156200036857620003676200012d565b5b62000376878288016200027e565b945050602085015167ffffffffffffffff8111156200039a57620003996200012d565b5b620003a8878288016200027e565b9350506040620003bb87828801620002d8565b9250506060620003ce8782880162000313565b91505092959194509250565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200042d57607f821691505b602082108103620004435762000442620003e5565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b60008160020a8302905092915050565b600060088302620004b07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826200046e565b620004bc86836200046e565b95508019841693508086168417925050509392505050565b6000819050919050565b6000620004ff620004f9620004f384620002ef565b620004d4565b620002ef565b9050919050565b6000819050919050565b6200051b83620004de565b620005336200052a8262000506565b8484546200047e565b825550505050565b600090565b6200054a6200053b565b6200055781848462000510565b505050565b5b818110156200057f576200057360008262000540565b6001810190506200055d565b5050565b601f821115620005ce57620005988162000449565b620005a3846200045e565b81016020851015620005b3578190505b620005cb620005c2856200045e565b8301826200055c565b50505b505050565b60008160020a8304905092915050565b6000620005f660001984600802620005d3565b1980831691505092915050565b6000620006118383620005e3565b9150826002028217905092915050565b6200062c82620003da565b67ffffffffffffffff8111156200064857620006476200014d565b5b62000654825462000414565b6200066182828562000583565b600060209050601f83116001811462000699576000841562000684578287015190505b62000690858262000603565b86555062000700565b601f198416620006a98662000449565b60005b82811015620006d357848901518255600182019150602085019450602081019050620006ac565b86831015620006f35784890151620006ef601f891682620005e3565b8355505b6001600288020188555050505b505050505050565b61172d80620007186000396000f3fe608060405234801561001057600080fd5b5060043610610133576000357c0100000000000000000000000000000000000000000000000000000000900480635f408c04116100bf578063a9059cbb1161008e578063a9059cbb1461033c578063b1cb0db31461036c578063da2824a81461038a578063dd62ed3e146103ba578063f2fde38b146103ea57610133565b80635f408c04146102b257806370a08231146102d05780638da5cb5b1461030057806395d89b411461031e57610133565b806323b872dd1161010657806323b872dd146101d45780632b29ba2314610204578063313ce56714610234578063449a52f8146102525780635356dddc1461028257610133565b806301ffc9a71461013857806306fdde0314610168578063095ea7b31461018657806318160ddd146101b6575b600080fd5b610152600480360381019061014d91906112cc565b61041a565b60405161015f9190611314565b60405180910390f35b61017061056e565b60405161017d91906113bf565b60405180910390f35b6101a0600480360381019061019b9190611475565b6105fc565b6040516101ad9190611314565b60405180910390f35b6101be610797565b6040516101cb91906114c4565b60405180910390f35b6101ee60048036038101906101e991906114df565b61079d565b6040516101fb9190611314565b60405180910390f35b61021e60048036038101906102199190611532565b610ac5565b60405161022b9190611314565b60405180910390f35b61023c610b71565b604051610249919061157b565b60405180910390f35b61026c60048036038101906102679190611475565b610b84565b6040516102799190611314565b60405180910390f35b61029c60048036038101906102979190611532565b610d10565b6040516102a99190611314565b60405180910390f35b6102ba610e02565b6040516102c7919061157b565b60405180910390f35b6102ea60048036038101906102e59190611532565b610ea0565b6040516102f791906114c4565b60405180910390f35b610308610eb8565b60405161031591906115a5565b60405180910390f35b610326610edc565b60405161033391906113bf565b60405180910390f35b61035660048036038101906103519190611475565b610f6a565b6040516103639190611314565b60405180910390f35b6103746110e9565b60405161038191906114c4565b60405180910390f35b6103a4600480360381019061039f9190611532565b6110ef565b6040516103b19190611314565b60405180910390f35b6103d460048036038101906103cf91906115c0565b6111aa565b6040516103e191906114c4565b60405180910390f35b61040460048036038101906103ff9190611532565b6111cf565b6040516104119190611314565b60405180910390f35b600063c6bb4b707c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361046e5760019050610569565b63449a52f87c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104c05760019050610569565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036105125760019050610569565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036105645760019050610569565b600090505b919050565b6002805461057b9061162f565b80601f01602080910402602001604051908101604052809291908181526020018280546105a79061162f565b80156105f45780601f106105c9576101008083540402835291602001916105f4565b820191906000526020600020905b8154815290600101906020018083116105d757829003601f168201915b505050505081565b600080610607610e02565b60ff161461061457600080fd5b60008211156106a7576000600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146106a657600080fd5b5b81600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161078591906114c4565b60405180910390a36001905092915050565b60055481565b6000806107a8610e02565b60ff16146107b557600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561083e57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561088a57600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610912919061168f565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109e1919061168f565b9250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610a3791906116c3565b925050819055503373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f5f7542858008eeb041631f30e6109ae94b83a58e9a58261dd2c42c508850f93985604051610ab291906114c4565b60405180910390a4600190509392505050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610b6a575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b9050919050565b600460009054906101000a900460ff1681565b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610c29575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610c3257600080fd5b81600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610c8191906116c3565b925050819055508160056000828254610c9a91906116c3565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f884604051610cfe91906114c4565b60405180910390a36001905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610d9857508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610da157600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60008060085403610e165760009050610e9d565b600960009054906101000a900460ff1615610e345760019050610e9d565b6008544210610e98576001600960006101000a81548160ff0219169083151502179055507ff80dbaea4785589e52984ca36a31de106adc77759539a5c7d92883bf49692fe942604051610e8791906114c4565b60405180910390a160029050610e9d565b600090505b90565b60066020528060005260406000206000915090505481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60038054610ee99061162f565b80601f0160208091040260200160405190810160405280929190818152602001828054610f159061162f565b8015610f625780601f10610f3757610100808354040283529160200191610f62565b820191906000526020600020905b815481529060010190602001808311610f4557829003601f168201915b505050505081565b600080610f75610e02565b60ff1614610f8257600080fd5b81600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610fce57600080fd5b81600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461101d919061168f565b9250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461107391906116c3565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516110d791906114c4565b60405180910390a36001905092915050565b60085481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461114a57600080fd5b60018060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6007602052816000526040600020602052806000526040600020600091509150505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461122a57600080fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6112a981611274565b81146112b457600080fd5b50565b6000813590506112c6816112a0565b92915050565b6000602082840312156112e2576112e161126f565b5b60006112f0848285016112b7565b91505092915050565b60008115159050919050565b61130e816112f9565b82525050565b60006020820190506113296000830184611305565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561136957808201518184015260208101905061134e565b60008484015250505050565b6000601f19601f8301169050919050565b60006113918261132f565b61139b818561133a565b93506113ab81856020860161134b565b6113b481611375565b840191505092915050565b600060208201905081810360008301526113d98184611386565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061140c826113e1565b9050919050565b61141c81611401565b811461142757600080fd5b50565b60008135905061143981611413565b92915050565b6000819050919050565b6114528161143f565b811461145d57600080fd5b50565b60008135905061146f81611449565b92915050565b6000806040838503121561148c5761148b61126f565b5b600061149a8582860161142a565b92505060206114ab85828601611460565b9150509250929050565b6114be8161143f565b82525050565b60006020820190506114d960008301846114b5565b92915050565b6000806000606084860312156114f8576114f761126f565b5b60006115068682870161142a565b93505060206115178682870161142a565b925050604061152886828701611460565b9150509250925092565b6000602082840312156115485761154761126f565b5b60006115568482850161142a565b91505092915050565b600060ff82169050919050565b6115758161155f565b82525050565b6000602082019050611590600083018461156c565b92915050565b61159f81611401565b82525050565b60006020820190506115ba6000830184611596565b92915050565b600080604083850312156115d7576115d661126f565b5b60006115e58582860161142a565b92505060206115f68582860161142a565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061164757607f821691505b60208210810361165a57611659611600565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061169a8261143f565b91506116a58361143f565b92508282039050818111156116bd576116bc611660565b5b92915050565b60006116ce8261143f565b91506116d98361143f565b92508282019050808211156116f1576116f0611660565b5b9291505056fea26469706673582212208aaa32a1e19a38a9c677c12685cac0eef1e83a25fdccc90a49a414e40771e53c64736f6c63430008120033 -\ No newline at end of file +60806040523480156200001157600080fd5b5060405162002200380380620022008339818101604052810190620000379190620002d3565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508360029081620000889190620005ca565b5082600390816200009a9190620005ca565b5081600460006101000a81548160ff021916908360ff1602179055508060098190555050505050620006b1565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6200013082620000e5565b810181811067ffffffffffffffff82111715620001525762000151620000f6565b5b80604052505050565b600062000167620000c7565b905062000175828262000125565b919050565b600067ffffffffffffffff821115620001985762000197620000f6565b5b620001a382620000e5565b9050602081019050919050565b60005b83811015620001d0578082015181840152602081019050620001b3565b60008484015250505050565b6000620001f3620001ed846200017a565b6200015b565b905082815260208101848484011115620002125762000211620000e0565b5b6200021f848285620001b0565b509392505050565b600082601f8301126200023f576200023e620000db565b5b815162000251848260208601620001dc565b91505092915050565b600060ff82169050919050565b62000272816200025a565b81146200027e57600080fd5b50565b600081519050620002928162000267565b92915050565b6000819050919050565b620002ad8162000298565b8114620002b957600080fd5b50565b600081519050620002cd81620002a2565b92915050565b60008060008060808587031215620002f057620002ef620000d1565b5b600085015167ffffffffffffffff811115620003115762000310620000d6565b5b6200031f8782880162000227565b945050602085015167ffffffffffffffff811115620003435762000342620000d6565b5b620003518782880162000227565b9350506040620003648782880162000281565b92505060606200037787828801620002bc565b91505092959194509250565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680620003d657607f821691505b602082108103620003ec57620003eb6200038e565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b60008160020a8302905092915050565b600060088302620004597fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000417565b62000465868362000417565b95508019841693508086168417925050509392505050565b6000819050919050565b6000620004a8620004a26200049c8462000298565b6200047d565b62000298565b9050919050565b6000819050919050565b620004c48362000487565b620004dc620004d382620004af565b84845462000427565b825550505050565b600090565b620004f3620004e4565b62000500818484620004b9565b505050565b5b8181101562000528576200051c600082620004e9565b60018101905062000506565b5050565b601f82111562000577576200054181620003f2565b6200054c8462000407565b810160208510156200055c578190505b620005746200056b8562000407565b83018262000505565b50505b505050565b60008160020a8304905092915050565b60006200059f600019846008026200057c565b1980831691505092915050565b6000620005ba83836200058c565b9150826002028217905092915050565b620005d58262000383565b67ffffffffffffffff811115620005f157620005f0620000f6565b5b620005fd8254620003bd565b6200060a8282856200052c565b600060209050601f8311600181146200064257600084156200062d578287015190505b620006398582620005ac565b865550620006a9565b601f1984166200065286620003f2565b60005b828110156200067c5784890151825560018201915060208501945060208101905062000655565b868310156200069c578489015162000698601f8916826200058c565b8355505b6001600288020188555050505b505050505050565b611b3f80620006c16000396000f3fe608060405234801561001057600080fd5b5060043610610154576000357c0100000000000000000000000000000000000000000000000000000000900480635f408c04116100d5578063a2309ff811610099578063a2309ff8146103ab578063a9059cbb146103c9578063b1cb0db3146103f9578063da2824a814610417578063dd62ed3e14610447578063f2fde38b1461047757610154565b80635f408c041461030357806370a082311461032157806373f42561146103515780638da5cb5b1461036f57806395d89b411461038d57610154565b80632b29ba231161011c5780632b29ba2314610225578063313ce5671461025557806342966c6814610273578063449a52f8146102a35780635356dddc146102d357610154565b806301ffc9a71461015957806306fdde0314610189578063095ea7b3146101a757806318160ddd146101d757806323b872dd146101f5575b600080fd5b610173600480360381019061016e91906115d9565b6104a7565b6040516101809190611621565b60405180910390f35b61019161069f565b60405161019e91906116cc565b60405180910390f35b6101c160048036038101906101bc9190611782565b61072d565b6040516101ce9190611621565b60405180910390f35b6101df6108c8565b6040516101ec91906117d1565b60405180910390f35b61020f600480360381019061020a91906117ec565b6108df565b60405161021c9190611621565b60405180910390f35b61023f600480360381019061023a919061183f565b610c07565b60405161024c9190611621565b60405180910390f35b61025d610cb3565b60405161026a9190611888565b60405180910390f35b61028d600480360381019061028891906118a3565b610cc6565b60405161029a9190611621565b60405180910390f35b6102bd60048036038101906102b89190611782565b610e84565b6040516102ca9190611621565b60405180910390f35b6102ed60048036038101906102e8919061183f565b611010565b6040516102fa9190611621565b60405180910390f35b61030b611102565b6040516103189190611888565b60405180910390f35b61033b6004803603810190610336919061183f565b6111a0565b60405161034891906117d1565b60405180910390f35b6103596111b8565b60405161036691906117d1565b60405180910390f35b6103776111be565b60405161038491906118df565b60405180910390f35b6103956111e2565b6040516103a291906116cc565b60405180910390f35b6103b3611270565b6040516103c091906117d1565b60405180910390f35b6103e360048036038101906103de9190611782565b611276565b6040516103f09190611621565b60405180910390f35b6104016113f5565b60405161040e91906117d1565b60405180910390f35b610431600480360381019061042c919061183f565b6113fb565b60405161043e9190611621565b60405180910390f35b610461600480360381019061045c91906118fa565b6114b7565b60405161046e91906117d1565b60405180910390f35b610491600480360381019061048c919061183f565b6114dc565b60405161049e9190611621565b60405180910390f35b600063c6bb4b707c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104fb576001905061069a565b63449a52f87c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361054d576001905061069a565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361059f576001905061069a565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036105f1576001905061069a565b63abe1f1f57c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610643576001905061069a565b63fccc2e797c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610695576001905061069a565b600090505b919050565b600280546106ac90611969565b80601f01602080910402602001604051908101604052809291908181526020018280546106d890611969565b80156107255780601f106106fa57610100808354040283529160200191610725565b820191906000526020600020905b81548152906001019060200180831161070857829003601f168201915b505050505081565b600080610738611102565b60ff161461074557600080fd5b60008211156107d8576000600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146107d757600080fd5b5b81600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516108b691906117d1565b60405180910390a36001905092915050565b60006008546007546108da91906119c9565b905090565b6000806108ea611102565b60ff16146108f757600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561098057600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156109cc57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610a5491906119c9565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b2391906119c9565b9250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b7991906119fd565b925050819055503373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f5f7542858008eeb041631f30e6109ae94b83a58e9a58261dd2c42c508850f93985604051610bf491906117d1565b60405180910390a4600190509392505050565b6000600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610cac575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b9050919050565b600460009054906101000a900460ff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d57576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4e90611a7d565b60405180910390fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610dd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd090611ae9565b60405180910390fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610e2891906119c9565b925050819055508160086000828254610e4191906119fd565b925050819055507fb90306ad06b2a6ff86ddc9327db583062895ef6540e62dc50add009db5b356eb82604051610e7791906117d1565b60405180910390a1919050565b6000600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610f29575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610f3257600080fd5b81600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610f8191906119fd565b925050819055508160076000828254610f9a91906119fd565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f884604051610ffe91906117d1565b60405180910390a36001905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061109857508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6110a157600080fd5b6000600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60008060095403611116576000905061119d565b600a60009054906101000a900460ff1615611134576001905061119d565b6009544210611198576001600a60006101000a81548160ff0219169083151502179055507ff80dbaea4785589e52984ca36a31de106adc77759539a5c7d92883bf49692fe94260405161118791906117d1565b60405180910390a16002905061119d565b600090505b90565b60056020528060005260406000206000915090505481565b60085481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600380546111ef90611969565b80601f016020809104026020016040519081016040528092919081815260200182805461121b90611969565b80156112685780601f1061123d57610100808354040283529160200191611268565b820191906000526020600020905b81548152906001019060200180831161124b57829003601f168201915b505050505081565b60075481565b600080611281611102565b60ff161461128e57600080fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156112da57600080fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461132991906119c9565b9250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461137f91906119fd565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516113e391906117d1565b60405180910390a36001905092915050565b60095481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461145657600080fd5b6001600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6006602052816000526040600020602052806000526040600020600091509150505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461153757600080fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6115b681611581565b81146115c157600080fd5b50565b6000813590506115d3816115ad565b92915050565b6000602082840312156115ef576115ee61157c565b5b60006115fd848285016115c4565b91505092915050565b60008115159050919050565b61161b81611606565b82525050565b60006020820190506116366000830184611612565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561167657808201518184015260208101905061165b565b60008484015250505050565b6000601f19601f8301169050919050565b600061169e8261163c565b6116a88185611647565b93506116b8818560208601611658565b6116c181611682565b840191505092915050565b600060208201905081810360008301526116e68184611693565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611719826116ee565b9050919050565b6117298161170e565b811461173457600080fd5b50565b60008135905061174681611720565b92915050565b6000819050919050565b61175f8161174c565b811461176a57600080fd5b50565b60008135905061177c81611756565b92915050565b600080604083850312156117995761179861157c565b5b60006117a785828601611737565b92505060206117b88582860161176d565b9150509250929050565b6117cb8161174c565b82525050565b60006020820190506117e660008301846117c2565b92915050565b6000806000606084860312156118055761180461157c565b5b600061181386828701611737565b935050602061182486828701611737565b92505060406118358682870161176d565b9150509250925092565b6000602082840312156118555761185461157c565b5b600061186384828501611737565b91505092915050565b600060ff82169050919050565b6118828161186c565b82525050565b600060208201905061189d6000830184611879565b92915050565b6000602082840312156118b9576118b861157c565b5b60006118c78482850161176d565b91505092915050565b6118d98161170e565b82525050565b60006020820190506118f460008301846118d0565b92915050565b600080604083850312156119115761191061157c565b5b600061191f85828601611737565b925050602061193085828601611737565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061198157607f821691505b6020821081036119945761199361193a565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006119d48261174c565b91506119df8361174c565b92508282039050818111156119f7576119f661199a565b5b92915050565b6000611a088261174c565b9150611a138361174c565b9250828201905080821115611a2b57611a2a61199a565b5b92915050565b7f4552525f41434345535300000000000000000000000000000000000000000000600082015250565b6000611a67600a83611647565b9150611a7282611a31565b602082019050919050565b60006020820190508181036000830152611a9681611a5a565b9050919050565b7f4552525f46554e44530000000000000000000000000000000000000000000000600082015250565b6000611ad3600983611647565b9150611ade82611a9d565b602082019050919050565b60006020820190508181036000830152611b0281611ac6565b905091905056fea2646970667358221220c4e008886dc0bfd42940dd2b7239b90cc61ec1d68ea065b11977d592b86bb88164736f6c63430008120033 +\ No newline at end of file diff --git a/python/giftable_erc20_token/data/GiftableToken.json b/python/giftable_erc20_token/data/GiftableToken.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint256","name":"_expireTimestamp","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Expired","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":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","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":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferFrom","type":"event"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"applyExpiry","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"expires","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"isWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"mintTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":"address","name":"_minter","type":"address"}],"name":"removeWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","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":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] +[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint256","name":"_expireTimestamp","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Expired","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":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","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":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferFrom","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterRemoved","type":"event"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"applyExpiry","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"burned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"expires","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"isWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"mintTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":"address","name":"_minter","type":"address"}],"name":"removeWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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/giftable_erc20_token/factory.py b/python/giftable_erc20_token/factory.py @@ -12,6 +12,9 @@ from chainlib.eth.contract import ( ABIContractEncoder, ABIContractType, ) +from chainlib.eth.constant import ZERO_ADDRESS +from chainlib.jsonrpc import JSONRPCRequest +from hexathon import add_0x # local imports from giftable_erc20_token.data import data_dir @@ -107,6 +110,48 @@ class GiftableToken(ERC20): return tx + def burn(self, contract_address, sender_address, value, tx_format=TxFormat.JSONRPC): + enc = ABIContractEncoder() + enc.method('burn') + enc.typ(ABIContractType.UINT256) + enc.uint256(value) + 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 burned(self, contract_address, sender_address=ZERO_ADDRESS, id_generator=None): + j = JSONRPCRequest(id_generator) + o = j.template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('burned') + 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') + o = j.finalize(o) + return o + + + def total_minted(self, contract_address, sender_address=ZERO_ADDRESS, id_generator=None): + j = JSONRPCRequest(id_generator) + o = j.template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('totalMinted') + 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') + o = j.finalize(o) + return o + + def bytecode(**kwargs): return GiftableToken.bytecode(version=kwargs.get('version')) diff --git a/python/tests/test_giftable.py b/python/tests/test_giftable.py @@ -80,5 +80,44 @@ class TestExpire(TestGiftableExpireToken): self.assertEqual(supply, mint_amount) + def test_burn(self): + mint_amount = self.initial_supply + nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) + c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.burn(self.address, self.accounts[1], int(mint_amount / 4)) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 0) + + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.burn(self.address, self.accounts[0], int(mint_amount / 4)) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + o = c.burned(self.address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + burned = c.parse_balance(r) + self.assertEqual(burned, int(mint_amount / 4)) + + o = c.balance_of(self.address, self.accounts[0], sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = c.parse_balance(r) + self.assertEqual(balance, mint_amount - burned) + + o = c.total_supply(self.address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = c.parse_balance(r) + self.assertEqual(balance, mint_amount - burned) + + o = c.total_minted(self.address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = c.parse_balance(r) + self.assertEqual(balance, mint_amount) + + if __name__ == '__main__': unittest.main() diff --git a/solidity/GiftableToken.bin b/solidity/GiftableToken.bin @@ -1 +1 @@ -60806040523480156200001157600080fd5b5060405162001e4538038062001e4583398181016040528101906200003791906200032a565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550836002908162000088919062000621565b5082600390816200009a919062000621565b5081600460006101000a81548160ff021916908360ff16021790555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550806008819055505050505062000708565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b62000187826200013c565b810181811067ffffffffffffffff82111715620001a957620001a86200014d565b5b80604052505050565b6000620001be6200011e565b9050620001cc82826200017c565b919050565b600067ffffffffffffffff821115620001ef57620001ee6200014d565b5b620001fa826200013c565b9050602081019050919050565b60005b83811015620002275780820151818401526020810190506200020a565b60008484015250505050565b60006200024a6200024484620001d1565b620001b2565b90508281526020810184848401111562000269576200026862000137565b5b6200027684828562000207565b509392505050565b600082601f83011262000296576200029562000132565b5b8151620002a884826020860162000233565b91505092915050565b600060ff82169050919050565b620002c981620002b1565b8114620002d557600080fd5b50565b600081519050620002e981620002be565b92915050565b6000819050919050565b6200030481620002ef565b81146200031057600080fd5b50565b6000815190506200032481620002f9565b92915050565b6000806000806080858703121562000347576200034662000128565b5b600085015167ffffffffffffffff8111156200036857620003676200012d565b5b62000376878288016200027e565b945050602085015167ffffffffffffffff8111156200039a57620003996200012d565b5b620003a8878288016200027e565b9350506040620003bb87828801620002d8565b9250506060620003ce8782880162000313565b91505092959194509250565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200042d57607f821691505b602082108103620004435762000442620003e5565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b60008160020a8302905092915050565b600060088302620004b07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826200046e565b620004bc86836200046e565b95508019841693508086168417925050509392505050565b6000819050919050565b6000620004ff620004f9620004f384620002ef565b620004d4565b620002ef565b9050919050565b6000819050919050565b6200051b83620004de565b620005336200052a8262000506565b8484546200047e565b825550505050565b600090565b6200054a6200053b565b6200055781848462000510565b505050565b5b818110156200057f576200057360008262000540565b6001810190506200055d565b5050565b601f821115620005ce57620005988162000449565b620005a3846200045e565b81016020851015620005b3578190505b620005cb620005c2856200045e565b8301826200055c565b50505b505050565b60008160020a8304905092915050565b6000620005f660001984600802620005d3565b1980831691505092915050565b6000620006118383620005e3565b9150826002028217905092915050565b6200062c82620003da565b67ffffffffffffffff8111156200064857620006476200014d565b5b62000654825462000414565b6200066182828562000583565b600060209050601f83116001811462000699576000841562000684578287015190505b62000690858262000603565b86555062000700565b601f198416620006a98662000449565b60005b82811015620006d357848901518255600182019150602085019450602081019050620006ac565b86831015620006f35784890151620006ef601f891682620005e3565b8355505b6001600288020188555050505b505050505050565b61172d80620007186000396000f3fe608060405234801561001057600080fd5b5060043610610133576000357c0100000000000000000000000000000000000000000000000000000000900480635f408c04116100bf578063a9059cbb1161008e578063a9059cbb1461033c578063b1cb0db31461036c578063da2824a81461038a578063dd62ed3e146103ba578063f2fde38b146103ea57610133565b80635f408c04146102b257806370a08231146102d05780638da5cb5b1461030057806395d89b411461031e57610133565b806323b872dd1161010657806323b872dd146101d45780632b29ba2314610204578063313ce56714610234578063449a52f8146102525780635356dddc1461028257610133565b806301ffc9a71461013857806306fdde0314610168578063095ea7b31461018657806318160ddd146101b6575b600080fd5b610152600480360381019061014d91906112cc565b61041a565b60405161015f9190611314565b60405180910390f35b61017061056e565b60405161017d91906113bf565b60405180910390f35b6101a0600480360381019061019b9190611475565b6105fc565b6040516101ad9190611314565b60405180910390f35b6101be610797565b6040516101cb91906114c4565b60405180910390f35b6101ee60048036038101906101e991906114df565b61079d565b6040516101fb9190611314565b60405180910390f35b61021e60048036038101906102199190611532565b610ac5565b60405161022b9190611314565b60405180910390f35b61023c610b71565b604051610249919061157b565b60405180910390f35b61026c60048036038101906102679190611475565b610b84565b6040516102799190611314565b60405180910390f35b61029c60048036038101906102979190611532565b610d10565b6040516102a99190611314565b60405180910390f35b6102ba610e02565b6040516102c7919061157b565b60405180910390f35b6102ea60048036038101906102e59190611532565b610ea0565b6040516102f791906114c4565b60405180910390f35b610308610eb8565b60405161031591906115a5565b60405180910390f35b610326610edc565b60405161033391906113bf565b60405180910390f35b61035660048036038101906103519190611475565b610f6a565b6040516103639190611314565b60405180910390f35b6103746110e9565b60405161038191906114c4565b60405180910390f35b6103a4600480360381019061039f9190611532565b6110ef565b6040516103b19190611314565b60405180910390f35b6103d460048036038101906103cf91906115c0565b6111aa565b6040516103e191906114c4565b60405180910390f35b61040460048036038101906103ff9190611532565b6111cf565b6040516104119190611314565b60405180910390f35b600063c6bb4b707c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361046e5760019050610569565b63449a52f87c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104c05760019050610569565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036105125760019050610569565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036105645760019050610569565b600090505b919050565b6002805461057b9061162f565b80601f01602080910402602001604051908101604052809291908181526020018280546105a79061162f565b80156105f45780601f106105c9576101008083540402835291602001916105f4565b820191906000526020600020905b8154815290600101906020018083116105d757829003601f168201915b505050505081565b600080610607610e02565b60ff161461061457600080fd5b60008211156106a7576000600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146106a657600080fd5b5b81600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161078591906114c4565b60405180910390a36001905092915050565b60055481565b6000806107a8610e02565b60ff16146107b557600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561083e57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561088a57600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610912919061168f565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109e1919061168f565b9250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610a3791906116c3565b925050819055503373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f5f7542858008eeb041631f30e6109ae94b83a58e9a58261dd2c42c508850f93985604051610ab291906114c4565b60405180910390a4600190509392505050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610b6a575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b9050919050565b600460009054906101000a900460ff1681565b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610c29575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610c3257600080fd5b81600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610c8191906116c3565b925050819055508160056000828254610c9a91906116c3565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f884604051610cfe91906114c4565b60405180910390a36001905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610d9857508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610da157600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60008060085403610e165760009050610e9d565b600960009054906101000a900460ff1615610e345760019050610e9d565b6008544210610e98576001600960006101000a81548160ff0219169083151502179055507ff80dbaea4785589e52984ca36a31de106adc77759539a5c7d92883bf49692fe942604051610e8791906114c4565b60405180910390a160029050610e9d565b600090505b90565b60066020528060005260406000206000915090505481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60038054610ee99061162f565b80601f0160208091040260200160405190810160405280929190818152602001828054610f159061162f565b8015610f625780601f10610f3757610100808354040283529160200191610f62565b820191906000526020600020905b815481529060010190602001808311610f4557829003601f168201915b505050505081565b600080610f75610e02565b60ff1614610f8257600080fd5b81600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610fce57600080fd5b81600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461101d919061168f565b9250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461107391906116c3565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516110d791906114c4565b60405180910390a36001905092915050565b60085481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461114a57600080fd5b60018060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6007602052816000526040600020602052806000526040600020600091509150505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461122a57600080fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6112a981611274565b81146112b457600080fd5b50565b6000813590506112c6816112a0565b92915050565b6000602082840312156112e2576112e161126f565b5b60006112f0848285016112b7565b91505092915050565b60008115159050919050565b61130e816112f9565b82525050565b60006020820190506113296000830184611305565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561136957808201518184015260208101905061134e565b60008484015250505050565b6000601f19601f8301169050919050565b60006113918261132f565b61139b818561133a565b93506113ab81856020860161134b565b6113b481611375565b840191505092915050565b600060208201905081810360008301526113d98184611386565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061140c826113e1565b9050919050565b61141c81611401565b811461142757600080fd5b50565b60008135905061143981611413565b92915050565b6000819050919050565b6114528161143f565b811461145d57600080fd5b50565b60008135905061146f81611449565b92915050565b6000806040838503121561148c5761148b61126f565b5b600061149a8582860161142a565b92505060206114ab85828601611460565b9150509250929050565b6114be8161143f565b82525050565b60006020820190506114d960008301846114b5565b92915050565b6000806000606084860312156114f8576114f761126f565b5b60006115068682870161142a565b93505060206115178682870161142a565b925050604061152886828701611460565b9150509250925092565b6000602082840312156115485761154761126f565b5b60006115568482850161142a565b91505092915050565b600060ff82169050919050565b6115758161155f565b82525050565b6000602082019050611590600083018461156c565b92915050565b61159f81611401565b82525050565b60006020820190506115ba6000830184611596565b92915050565b600080604083850312156115d7576115d661126f565b5b60006115e58582860161142a565b92505060206115f68582860161142a565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061164757607f821691505b60208210810361165a57611659611600565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061169a8261143f565b91506116a58361143f565b92508282039050818111156116bd576116bc611660565b5b92915050565b60006116ce8261143f565b91506116d98361143f565b92508282019050808211156116f1576116f0611660565b5b9291505056fea26469706673582212208aaa32a1e19a38a9c677c12685cac0eef1e83a25fdccc90a49a414e40771e53c64736f6c63430008120033 -\ No newline at end of file +60806040523480156200001157600080fd5b5060405162002200380380620022008339818101604052810190620000379190620002d3565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508360029081620000889190620005ca565b5082600390816200009a9190620005ca565b5081600460006101000a81548160ff021916908360ff1602179055508060098190555050505050620006b1565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6200013082620000e5565b810181811067ffffffffffffffff82111715620001525762000151620000f6565b5b80604052505050565b600062000167620000c7565b905062000175828262000125565b919050565b600067ffffffffffffffff821115620001985762000197620000f6565b5b620001a382620000e5565b9050602081019050919050565b60005b83811015620001d0578082015181840152602081019050620001b3565b60008484015250505050565b6000620001f3620001ed846200017a565b6200015b565b905082815260208101848484011115620002125762000211620000e0565b5b6200021f848285620001b0565b509392505050565b600082601f8301126200023f576200023e620000db565b5b815162000251848260208601620001dc565b91505092915050565b600060ff82169050919050565b62000272816200025a565b81146200027e57600080fd5b50565b600081519050620002928162000267565b92915050565b6000819050919050565b620002ad8162000298565b8114620002b957600080fd5b50565b600081519050620002cd81620002a2565b92915050565b60008060008060808587031215620002f057620002ef620000d1565b5b600085015167ffffffffffffffff811115620003115762000310620000d6565b5b6200031f8782880162000227565b945050602085015167ffffffffffffffff811115620003435762000342620000d6565b5b620003518782880162000227565b9350506040620003648782880162000281565b92505060606200037787828801620002bc565b91505092959194509250565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680620003d657607f821691505b602082108103620003ec57620003eb6200038e565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b60008160020a8302905092915050565b600060088302620004597fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000417565b62000465868362000417565b95508019841693508086168417925050509392505050565b6000819050919050565b6000620004a8620004a26200049c8462000298565b6200047d565b62000298565b9050919050565b6000819050919050565b620004c48362000487565b620004dc620004d382620004af565b84845462000427565b825550505050565b600090565b620004f3620004e4565b62000500818484620004b9565b505050565b5b8181101562000528576200051c600082620004e9565b60018101905062000506565b5050565b601f82111562000577576200054181620003f2565b6200054c8462000407565b810160208510156200055c578190505b620005746200056b8562000407565b83018262000505565b50505b505050565b60008160020a8304905092915050565b60006200059f600019846008026200057c565b1980831691505092915050565b6000620005ba83836200058c565b9150826002028217905092915050565b620005d58262000383565b67ffffffffffffffff811115620005f157620005f0620000f6565b5b620005fd8254620003bd565b6200060a8282856200052c565b600060209050601f8311600181146200064257600084156200062d578287015190505b620006398582620005ac565b865550620006a9565b601f1984166200065286620003f2565b60005b828110156200067c5784890151825560018201915060208501945060208101905062000655565b868310156200069c578489015162000698601f8916826200058c565b8355505b6001600288020188555050505b505050505050565b611b3f80620006c16000396000f3fe608060405234801561001057600080fd5b5060043610610154576000357c0100000000000000000000000000000000000000000000000000000000900480635f408c04116100d5578063a2309ff811610099578063a2309ff8146103ab578063a9059cbb146103c9578063b1cb0db3146103f9578063da2824a814610417578063dd62ed3e14610447578063f2fde38b1461047757610154565b80635f408c041461030357806370a082311461032157806373f42561146103515780638da5cb5b1461036f57806395d89b411461038d57610154565b80632b29ba231161011c5780632b29ba2314610225578063313ce5671461025557806342966c6814610273578063449a52f8146102a35780635356dddc146102d357610154565b806301ffc9a71461015957806306fdde0314610189578063095ea7b3146101a757806318160ddd146101d757806323b872dd146101f5575b600080fd5b610173600480360381019061016e91906115d9565b6104a7565b6040516101809190611621565b60405180910390f35b61019161069f565b60405161019e91906116cc565b60405180910390f35b6101c160048036038101906101bc9190611782565b61072d565b6040516101ce9190611621565b60405180910390f35b6101df6108c8565b6040516101ec91906117d1565b60405180910390f35b61020f600480360381019061020a91906117ec565b6108df565b60405161021c9190611621565b60405180910390f35b61023f600480360381019061023a919061183f565b610c07565b60405161024c9190611621565b60405180910390f35b61025d610cb3565b60405161026a9190611888565b60405180910390f35b61028d600480360381019061028891906118a3565b610cc6565b60405161029a9190611621565b60405180910390f35b6102bd60048036038101906102b89190611782565b610e84565b6040516102ca9190611621565b60405180910390f35b6102ed60048036038101906102e8919061183f565b611010565b6040516102fa9190611621565b60405180910390f35b61030b611102565b6040516103189190611888565b60405180910390f35b61033b6004803603810190610336919061183f565b6111a0565b60405161034891906117d1565b60405180910390f35b6103596111b8565b60405161036691906117d1565b60405180910390f35b6103776111be565b60405161038491906118df565b60405180910390f35b6103956111e2565b6040516103a291906116cc565b60405180910390f35b6103b3611270565b6040516103c091906117d1565b60405180910390f35b6103e360048036038101906103de9190611782565b611276565b6040516103f09190611621565b60405180910390f35b6104016113f5565b60405161040e91906117d1565b60405180910390f35b610431600480360381019061042c919061183f565b6113fb565b60405161043e9190611621565b60405180910390f35b610461600480360381019061045c91906118fa565b6114b7565b60405161046e91906117d1565b60405180910390f35b610491600480360381019061048c919061183f565b6114dc565b60405161049e9190611621565b60405180910390f35b600063c6bb4b707c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104fb576001905061069a565b63449a52f87c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361054d576001905061069a565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361059f576001905061069a565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036105f1576001905061069a565b63abe1f1f57c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610643576001905061069a565b63fccc2e797c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610695576001905061069a565b600090505b919050565b600280546106ac90611969565b80601f01602080910402602001604051908101604052809291908181526020018280546106d890611969565b80156107255780601f106106fa57610100808354040283529160200191610725565b820191906000526020600020905b81548152906001019060200180831161070857829003601f168201915b505050505081565b600080610738611102565b60ff161461074557600080fd5b60008211156107d8576000600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146107d757600080fd5b5b81600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516108b691906117d1565b60405180910390a36001905092915050565b60006008546007546108da91906119c9565b905090565b6000806108ea611102565b60ff16146108f757600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561098057600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156109cc57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610a5491906119c9565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b2391906119c9565b9250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b7991906119fd565b925050819055503373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f5f7542858008eeb041631f30e6109ae94b83a58e9a58261dd2c42c508850f93985604051610bf491906117d1565b60405180910390a4600190509392505050565b6000600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610cac575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b9050919050565b600460009054906101000a900460ff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d57576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4e90611a7d565b60405180910390fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610dd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd090611ae9565b60405180910390fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610e2891906119c9565b925050819055508160086000828254610e4191906119fd565b925050819055507fb90306ad06b2a6ff86ddc9327db583062895ef6540e62dc50add009db5b356eb82604051610e7791906117d1565b60405180910390a1919050565b6000600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610f29575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610f3257600080fd5b81600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610f8191906119fd565b925050819055508160076000828254610f9a91906119fd565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f884604051610ffe91906117d1565b60405180910390a36001905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061109857508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6110a157600080fd5b6000600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60008060095403611116576000905061119d565b600a60009054906101000a900460ff1615611134576001905061119d565b6009544210611198576001600a60006101000a81548160ff0219169083151502179055507ff80dbaea4785589e52984ca36a31de106adc77759539a5c7d92883bf49692fe94260405161118791906117d1565b60405180910390a16002905061119d565b600090505b90565b60056020528060005260406000206000915090505481565b60085481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600380546111ef90611969565b80601f016020809104026020016040519081016040528092919081815260200182805461121b90611969565b80156112685780601f1061123d57610100808354040283529160200191611268565b820191906000526020600020905b81548152906001019060200180831161124b57829003601f168201915b505050505081565b60075481565b600080611281611102565b60ff161461128e57600080fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156112da57600080fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461132991906119c9565b9250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461137f91906119fd565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516113e391906117d1565b60405180910390a36001905092915050565b60095481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461145657600080fd5b6001600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6006602052816000526040600020602052806000526040600020600091509150505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461153757600080fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6115b681611581565b81146115c157600080fd5b50565b6000813590506115d3816115ad565b92915050565b6000602082840312156115ef576115ee61157c565b5b60006115fd848285016115c4565b91505092915050565b60008115159050919050565b61161b81611606565b82525050565b60006020820190506116366000830184611612565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561167657808201518184015260208101905061165b565b60008484015250505050565b6000601f19601f8301169050919050565b600061169e8261163c565b6116a88185611647565b93506116b8818560208601611658565b6116c181611682565b840191505092915050565b600060208201905081810360008301526116e68184611693565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611719826116ee565b9050919050565b6117298161170e565b811461173457600080fd5b50565b60008135905061174681611720565b92915050565b6000819050919050565b61175f8161174c565b811461176a57600080fd5b50565b60008135905061177c81611756565b92915050565b600080604083850312156117995761179861157c565b5b60006117a785828601611737565b92505060206117b88582860161176d565b9150509250929050565b6117cb8161174c565b82525050565b60006020820190506117e660008301846117c2565b92915050565b6000806000606084860312156118055761180461157c565b5b600061181386828701611737565b935050602061182486828701611737565b92505060406118358682870161176d565b9150509250925092565b6000602082840312156118555761185461157c565b5b600061186384828501611737565b91505092915050565b600060ff82169050919050565b6118828161186c565b82525050565b600060208201905061189d6000830184611879565b92915050565b6000602082840312156118b9576118b861157c565b5b60006118c78482850161176d565b91505092915050565b6118d98161170e565b82525050565b60006020820190506118f460008301846118d0565b92915050565b600080604083850312156119115761191061157c565b5b600061191f85828601611737565b925050602061193085828601611737565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061198157607f821691505b6020821081036119945761199361193a565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006119d48261174c565b91506119df8361174c565b92508282039050818111156119f7576119f661199a565b5b92915050565b6000611a088261174c565b9150611a138361174c565b9250828201905080821115611a2b57611a2a61199a565b5b92915050565b7f4552525f41434345535300000000000000000000000000000000000000000000600082015250565b6000611a67600a83611647565b9150611a7282611a31565b602082019050919050565b60006020820190508181036000830152611a9681611a5a565b9050919050565b7f4552525f46554e44530000000000000000000000000000000000000000000000600082015250565b6000611ad3600983611647565b9150611ade82611a9d565b602082019050919050565b60006020820190508181036000830152611b0281611ac6565b905091905056fea2646970667358221220c4e008886dc0bfd42940dd2b7239b90cc61ec1d68ea065b11977d592b86bb88164736f6c63430008120033 +\ No newline at end of file diff --git a/solidity/GiftableToken.json b/solidity/GiftableToken.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint256","name":"_expireTimestamp","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Expired","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":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","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":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferFrom","type":"event"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"applyExpiry","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"expires","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"isWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"mintTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":"address","name":"_minter","type":"address"}],"name":"removeWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","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":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] +[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint256","name":"_expireTimestamp","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Expired","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":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","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":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferFrom","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterRemoved","type":"event"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"applyExpiry","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"burned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"expires","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"isWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"mintTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":"address","name":"_minter","type":"address"}],"name":"removeWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/solidity/GiftableToken.sol b/solidity/GiftableToken.sol @@ -5,8 +5,11 @@ pragma solidity >=0.6.11; contract GiftableToken { + // Implements EIP173 address public owner; - mapping(address => bool) minters; + + // Implements Writer + mapping(address => bool) writer; // Implements ERC20 string public name; @@ -15,62 +18,90 @@ contract GiftableToken { // Implements ERC20 uint8 public decimals; // Implements ERC20 - uint256 public totalSupply; - // Implements ERC20 mapping (address => uint256) public balanceOf; // Implements ERC20 mapping (address => mapping (address => uint256)) public allowance; - // timestamp when token contract expires + // Implements Burner + uint256 public totalMinted; + // Implements Burner + uint256 public burned; + + // Implements expire uint256 public expires; bool expired; + // Implements ERC20 event Transfer(address indexed _from, address indexed _to, uint256 _value); + // Implements ERC20 event TransferFrom(address indexed _from, address indexed _to, address indexed _spender, uint256 _value); + // Implements ERC20 event Approval(address indexed _owner, address indexed _spender, uint256 _value); + + // Implements Minter event Mint(address indexed _minter, address indexed _beneficiary, uint256 _value); + + // Implement Expire event Expired(uint256 _timestamp); + // Implements Writer + event WriterAdded(address _writer); + // Implements Writer + event WriterRemoved(address _writer); + + // Implements Burner + event Burn(uint256 _value); + constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _expireTimestamp) public { owner = msg.sender; name = _name; symbol = _symbol; decimals = _decimals; - minters[msg.sender] = true; expires = _expireTimestamp; } + // Implements ERC20 + function totalSupply() public returns (uint256) { + return totalMinted - burned; + } + + // Implements Minter + mapping(address => bool) writers; function mintTo(address _to, uint256 _value) public returns (bool) { - require(minters[msg.sender] || msg.sender == owner); + require(writers[msg.sender] || msg.sender == owner); balanceOf[_to] += _value; - totalSupply += _value; + totalMinted += _value; emit Mint(msg.sender, _to, _value); return true; } + // Implements Writer function addWriter(address _minter) public returns (bool) { require(msg.sender == owner); - minters[_minter] = true; + writers[_minter] = true; return true; } + // Implements Writer function removeWriter(address _minter) public returns (bool) { require(msg.sender == owner || msg.sender == _minter); - minters[_minter] = false; + writers[_minter] = false; return true; } + // Implements Writer function isWriter(address _minter) public view returns(bool) { - return minters[_minter] || _minter == owner; + return writers[_minter] || _minter == owner; } + // Implements Expire function applyExpiry() public returns(uint8) { if (expires == 0) { return 0; @@ -97,6 +128,17 @@ contract GiftableToken { return true; } + // Implements Burner + function burn(uint256 _value) public returns (bool) { + require(msg.sender == owner, 'ERR_ACCESS'); + require(balanceOf[msg.sender] >= _value, 'ERR_FUNDS'); + + balanceOf[msg.sender] -= _value; + burned += _value; + + emit Burn(_value); + } + // Implements ERC20 function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(applyExpiry() == 0); @@ -140,6 +182,12 @@ contract GiftableToken { if (_sum == 0x9493f8b2) { // EIP173 return true; } + if (_sum == 0xabe1f1f5) { // Writer + return true; + } + if (_sum == 0xfccc2e79) { // Burner + return true; + } return false; } }