eth-erc721

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

commit 569d014e18251ec2bb1b3412b104e21504e30945
parent c8322bedc429a7a52d3ae599b9f3b4b517012b9b
Author: nolash <dev@holbrook.no>
Date:   Fri,  7 May 2021 21:45:27 +0200

Add deploy test

Diffstat:
A.gitignore | 7+++++++
Apython/eth_devbadge/data/BadgeToken.bin | 2++
Apython/eth_devbadge/data/BadgeToken.json | 1+
Apython/eth_devbadge/token.py | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apython/requirements.txt | 1+
Apython/test_requirements.txt | 3+++
Apython/tests/test_app.py | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Asolidity/Makefile | 10++++++++++
8 files changed, 134 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,7 @@ +__pycache__ +*.pyc +python/build/ +python/dist/ +python/*.egg-info +solidity/*.json +solidity/*.bin diff --git a/python/eth_devbadge/data/BadgeToken.bin b/python/eth_devbadge/data/BadgeToken.bin @@ -0,0 +1 @@ +60806040523480156200001157600080fd5b50604051620025953803806200259583398181016040528101906200003791906200022c565b826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600c9080519060200190620000d0929190620000f3565b5080600d9080519060200190620000e9929190620000f3565b5050505062000472565b82805462000101906200037d565b90600052602060002090601f01602090048101928262000125576000855562000171565b82601f106200014057805160ff191683800117855562000171565b8280016001018555821562000171579182015b828111156200017057825182559160200191906001019062000153565b5b50905062000180919062000184565b5090565b5b808211156200019f57600081600090555060010162000185565b5090565b6000620001ba620001b484620002dd565b620002b4565b905082815260208101848484011115620001d357600080fd5b620001e084828562000347565b509392505050565b600081519050620001f98162000458565b92915050565b600082601f8301126200021157600080fd5b815162000223848260208601620001a3565b91505092915050565b6000806000606084860312156200024257600080fd5b60006200025286828701620001e8565b935050602084015167ffffffffffffffff8111156200027057600080fd5b6200027e86828701620001ff565b925050604084015167ffffffffffffffff8111156200029c57600080fd5b620002aa86828701620001ff565b9150509250925092565b6000620002c0620002d3565b9050620002ce8282620003b3565b919050565b6000604051905090565b600067ffffffffffffffff821115620002fb57620002fa62000418565b5b620003068262000447565b9050602081019050919050565b6000620003208262000327565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60005b83811015620003675780820151818401526020810190506200034a565b8381111562000377576000848401525b50505050565b600060028204905060018216806200039657607f821691505b60208210811415620003ad57620003ac620003e9565b5b50919050565b620003be8262000447565b810181811067ffffffffffffffff82111715620003e057620003df62000418565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b620004638162000313565b81146200046f57600080fd5b50565b61211380620004826000396000f3fe608060405260043610610131576000357c0100000000000000000000000000000000000000000000000000000000900480634f6ccce7116100bd57806395d89b411161008157806395d89b41146103e1578063a22cb4651461040c578063b88d4fde14610435578063e985e9c514610451578063f1b0aa151461048e57610131565b80634f6ccce7146102d45780636352211e1461031157806370a082311461034e5780638da5cb5b1461038b57806392088cf6146103b657610131565b806318160ddd1161010457806318160ddd146101f757806323b872dd146102225780632f745c591461023e57806342842e0e1461027b578063449a52f81461029757610131565b806301ffc9a71461013657806306fdde0314610173578063081812fc1461019e578063095ea7b3146101db575b600080fd5b34801561014257600080fd5b5061015d60048036038101906101589190611bf2565b6104cb565b60405161016a9190611cd4565b60405180910390f35b34801561017f57600080fd5b50610188610676565b6040516101959190611d0a565b60405180910390f35b3480156101aa57600080fd5b506101c560048036038101906101c09190611c1b565b610704565b6040516101d29190611cb9565b60405180910390f35b6101f560048036038101906101f09190611bb6565b610741565b005b34801561020357600080fd5b5061020c61085d565b6040516102199190611d2c565b60405180910390f35b61023c60048036038101906102379190611ab0565b61086a565b005b34801561024a57600080fd5b5061026560048036038101906102609190611bb6565b6108d9565b6040516102729190611d2c565b60405180910390f35b61029560048036038101906102909190611ab0565b6109b0565b005b3480156102a357600080fd5b506102be60048036038101906102b99190611bb6565b610a1f565b6040516102cb9190611cd4565b60405180910390f35b3480156102e057600080fd5b506102fb60048036038101906102f69190611c1b565b610cd3565b6040516103089190611d2c565b60405180910390f35b34801561031d57600080fd5b5061033860048036038101906103339190611c1b565b610d21565b6040516103459190611cb9565b60405180910390f35b34801561035a57600080fd5b5061037560048036038101906103709190611a4b565b610d5e565b6040516103829190611d2c565b60405180910390f35b34801561039757600080fd5b506103a0610da7565b6040516103ad9190611cb9565b60405180910390f35b3480156103c257600080fd5b506103cb610dcd565b6040516103d89190611cb9565b60405180910390f35b3480156103ed57600080fd5b506103f6610df1565b6040516104039190611d0a565b60405180910390f35b34801561041857600080fd5b50610433600480360381019061042e9190611b7a565b610e7f565b005b61044f600480360381019061044a9190611aff565b611122565b005b34801561045d57600080fd5b5061047860048036038101906104739190611a74565b61126c565b6040516104859190611cd4565b60405180910390f35b34801561049a57600080fd5b506104b560048036038101906104b09190611c1b565b611304565b6040516104c29190611d2c565b60405180910390f35b60006380ac58cd7c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156105205760019050610671565b635b5e139f7c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156105735760019050610671565b63780e9d637c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156105c65760019050610671565b63449a52f87c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156106195760019050610671565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561066c5760019050610671565b600090505b919050565b600c805461068390611ed7565b80601f01602080910402602001604051908101604052809291908181526020018280546106af90611ed7565b80156106fc5780601f106106d1576101008083540402835291602001916106fc565b820191906000526020600020905b8154815290600101906020018083116106df57829003601f168201915b505050505081565b60006009600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b3373ffffffffffffffffffffffffffffffffffffffff166005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107ac57600080fd5b816009600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000600280549050905090565b60606108788484848461136a565b818373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a450505050565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821061092657600080fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020828154811061099d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154905092915050565b60606109be8484848461136a565b818373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a450505050565b60003373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a7b57600080fd5b6000600460008481526020019081526020016000205414610a9b57600080fd5b600080600280549050915083905060028190806001815401808255809150506001900390600052602060002001600090919091909150556003439080600181540180825580915050600190039060005260206000200160009091909190915055846005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508360076000600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050815260200190815260200160002081905550600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020849080600181540180825580915050600190039060005260206000200160009091909190915055600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610c5d90611f3a565b91905055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f886604051610cbf9190611d2c565b60405180910390a360019250505092915050565b600060028281548110610d0f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b60006005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600d8054610dfe90611ed7565b80601f0160208091040260200160405190810160405280929190818152602001828054610e2a90611ed7565b8015610e775780601f10610e4c57610100808354040283529160200191610e77565b820191906000526020600020905b815481529060010190602001808311610e5a57829003601f168201915b505050505081565b8015610fa057600073ffffffffffffffffffffffffffffffffffffffff16600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f1d57600080fd5b81600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506110b9565b600073ffffffffffffffffffffffffffffffffffffffff16600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561103957600080fd5b6000600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b8173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516111169190611cd4565b60405180910390a35050565b61112e8484848461136a565b818373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4818373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f75c9e114f073c346aac7d1d7e9a3c3c14edabcdd27de07d1d9e425f45d318c5e600b60008781526020019081526020016000206001600b60008981526020019081526020016000208054905061120f9190611db9565b81548110611246577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015460405161125e9190611cef565b60405180910390a450505050565b60008173ffffffffffffffffffffffffffffffffffffffff16600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614905092915050565b6000806004600084815260200190815260200160002054905060038181548110611357577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154915050919050565b60006005600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508473ffffffffffffffffffffffffffffffffffffffff166005600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461140d57600080fd5b3373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614611541573373ffffffffffffffffffffffffffffffffffffffff166009600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061153757503373ffffffffffffffffffffffffffffffffffffffff16600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b61154057600080fd5b5b60006009600085815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001600660008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490506116229190611db9565b81548110611659577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206007600086815260200190815260200160002054815481106116ee577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061174c90611ead565b9190505550600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020839080600181540180825580915050600190039060005260206000200160009091909190915055600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061180790611f3a565b9190505550836005600085815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060005b8251811015611987578281815181106118a3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916600b600086815260200190815260200160002060208361192f9190611f83565b81548110611966577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550808061197f90611f3a565b915050611861565b505050505050565b60006119a261199d84611d6c565b611d47565b9050828152602081018484840111156119ba57600080fd5b6119c5848285611e6b565b509392505050565b6000813590506119dc81612081565b92915050565b6000813590506119f181612098565b92915050565b600081359050611a06816120af565b92915050565b600082601f830112611a1d57600080fd5b8135611a2d84826020860161198f565b91505092915050565b600081359050611a45816120c6565b92915050565b600060208284031215611a5d57600080fd5b6000611a6b848285016119cd565b91505092915050565b60008060408385031215611a8757600080fd5b6000611a95858286016119cd565b9250506020611aa6858286016119cd565b9150509250929050565b600080600060608486031215611ac557600080fd5b6000611ad3868287016119cd565b9350506020611ae4868287016119cd565b9250506040611af586828701611a36565b9150509250925092565b60008060008060808587031215611b1557600080fd5b6000611b23878288016119cd565b9450506020611b34878288016119cd565b9350506040611b4587828801611a36565b925050606085013567ffffffffffffffff811115611b6257600080fd5b611b6e87828801611a0c565b91505092959194509250565b60008060408385031215611b8d57600080fd5b6000611b9b858286016119cd565b9250506020611bac858286016119e2565b9150509250929050565b60008060408385031215611bc957600080fd5b6000611bd7858286016119cd565b9250506020611be885828601611a36565b9150509250929050565b600060208284031215611c0457600080fd5b6000611c12848285016119f7565b91505092915050565b600060208284031215611c2d57600080fd5b6000611c3b84828501611a36565b91505092915050565b611c4d81611ded565b82525050565b611c5c81611dff565b82525050565b611c6b81611e0b565b82525050565b6000611c7c82611d9d565b611c868185611da8565b9350611c96818560208601611e7a565b611c9f81612070565b840191505092915050565b611cb381611e61565b82525050565b6000602082019050611cce6000830184611c44565b92915050565b6000602082019050611ce96000830184611c53565b92915050565b6000602082019050611d046000830184611c62565b92915050565b60006020820190508181036000830152611d248184611c71565b905092915050565b6000602082019050611d416000830184611caa565b92915050565b6000611d51611d62565b9050611d5d8282611f09565b919050565b6000604051905090565b600067ffffffffffffffff821115611d8757611d86612041565b5b611d9082612070565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b6000611dc482611e61565b9150611dcf83611e61565b925082821015611de257611de1611fb4565b5b828203905092915050565b6000611df882611e41565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015611e98578082015181840152602081019050611e7d565b83811115611ea7576000848401525b50505050565b6000611eb882611e61565b91506000821415611ecc57611ecb611fb4565b5b600182039050919050565b60006002820490506001821680611eef57607f821691505b60208210811415611f0357611f02612012565b5b50919050565b611f1282612070565b810181811067ffffffffffffffff82111715611f3157611f30612041565b5b80604052505050565b6000611f4582611e61565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415611f7857611f77611fb4565b5b600182019050919050565b6000611f8e82611e61565b9150611f9983611e61565b925082611fa957611fa8611fe3565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b61208a81611ded565b811461209557600080fd5b50565b6120a181611dff565b81146120ac57600080fd5b50565b6120b881611e15565b81146120c357600080fd5b50565b6120cf81611e61565b81146120da57600080fd5b5056fea2646970667358221220ec8c2304ba3304f64a599e11d17f4e6846f6308e7446df317179c17b3220f7a764736f6c63430008030033 +\ No newline at end of file diff --git a/python/eth_devbadge/data/BadgeToken.json b/python/eth_devbadge/data/BadgeToken.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_operator","type":"address"},{"indexed":false,"internalType":"bool","name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_minter","type":"address"},{"indexed":true,"internalType":"address","name":"_beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"_data","type":"bytes32"}],"name":"TransferWithData","type":"event"},{"inputs":[{"internalType":"address","name":"_approved","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"declarator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"mintTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"mintedAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"bool","name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"payable","type":"function"}] diff --git a/python/eth_devbadge/token.py b/python/eth_devbadge/token.py @@ -0,0 +1,58 @@ +# standard imports +import os + +# external imports +from chainlib.eth.tx import ( + TxFormat, + TxFactory, + ) +from chainlib.eth.contract import ( + ABIContractEncoder, + ABIContractType, + ) + +# local imports +#from .interface import BadgeToken + +moddir = os.path.dirname(__file__) +datadir = os.path.join(moddir, 'data') + + +class BadgeToken(TxFactory): + + __abi = None + __bytecode = None + + @staticmethod + def abi(): + if BadgeToken.__abi == None: + f = open(os.path.join(datadir, 'BadgeToken.json'), 'r') + BadgeToken.__abi = json.load(f) + f.close() + return BadgeToken.__abi + + + @staticmethod + def bytecode(): + if BadgeToken.__bytecode == None: + f = open(os.path.join(datadir, 'BadgeToken.bin')) + BadgeToken.__bytecode = f.read() + f.close() + return BadgeToken.__bytecode + + + @staticmethod + def gas(code=None): + return 1200000 + + + def constructor(self, sender_address, declarator, name, symbol, tx_format=TxFormat.JSONRPC): + code = BadgeToken.bytecode() + enc = ABIContractEncoder() + enc.address(declarator) + enc.string(name) + enc.string(symbol) + code += enc.get() + tx = self.template(sender_address, None, use_nonce=True) + tx = self.set_code(tx, code) + return self.finalize(tx, tx_format) diff --git a/python/requirements.txt b/python/requirements.txt @@ -0,0 +1 @@ +chainlib~=0.0.3a2 diff --git a/python/test_requirements.txt b/python/test_requirements.txt @@ -0,0 +1,3 @@ +eth_tester==0.5.0b3 +py-evm==0.3.0a20 +pytest==6.0.1 diff --git a/python/tests/test_app.py b/python/tests/test_app.py @@ -0,0 +1,52 @@ +# standard imports +import os +import unittest +import json +import logging + +# external imports +from chainlib.eth.unittest.ethtester import EthTesterCase +from chainlib.connection import RPCConnection +from chainlib.eth.nonce import RPCNonceOracle +from chainlib.eth.address import to_checksum_address +from chainlib.eth.tx import ( + receipt, + transaction, + TxFormat, + ) +from chainlib.eth.contract import ( + abi_decode_single, + ABIContractType, + ) + +# local imports +from eth_devbadge.token import BadgeToken + +logging.basicConfig(level=logging.DEBUG) +logg = logging.getLogger() + +testdir = os.path.dirname(__file__) + + +class Test(EthTesterCase): + + def setUp(self): + super(Test, self).setUp() + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.constructor(self.accounts[0], b'\x00' * 20, 'DevBadge', 'DEV') + self.conn = RPCConnection.connect(self.chain_spec, 'default') + r = self.conn.do(o) + logg.debug('deployed with hash {}'.format(r)) + + o = receipt(r) + r = self.conn.do(o) + self.address = to_checksum_address(r['contract_address']) + + + def test_mint(self): + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/solidity/Makefile b/solidity/Makefile @@ -0,0 +1,10 @@ +SOLC = /usr/bin/solc + +all: + $(SOLC) --bin BadgeToken.sol --evm-version byzantium | awk 'NR>3' > BadgeToken.bin + truncate -s -1 BadgeToken.bin + $(SOLC) --abi BadgeToken.sol --evm-version byzantium | awk 'NR>3' > BadgeToken.json + +install: all + cp -v *{json,bin} ../python/eth_devbadge/data/ +