// Contract taken from Starknet-Edu: // https://github.com/starknet-edu/starknet-erc721/blob/b21972ca1c976afb7a401f8c4bedaa35606bd028/contracts/token/ERC721/ERC721.cairo %lang starknet from starkware.cairo.common.cairo_builtins import HashBuiltin, SignatureBuiltin from starkware.cairo.common.uint256 import Uint256 from openzeppelin.token.erc721.library import ERC721 // // Constructor // @constructor func constructor{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( name: felt, symbol: felt, to_: felt ) { ERC721.initializer(name, symbol); let to = to_; let token_id: Uint256 = Uint256(1, 0); ERC721._mint(to, token_id); return (); } // // Getters // @view func name{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}() -> (name: felt) { let (name) = ERC721.name(); return (name,); } @view func symbol{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}() -> (symbol: felt) { let (symbol) = ERC721.symbol(); return (symbol,); } @view func balanceOf{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}(owner: felt) -> ( balance: Uint256 ) { let (balance: Uint256) = ERC721.balance_of(owner); return (balance,); } @view func ownerOf{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( token_id: Uint256 ) -> (owner: felt) { let (owner: felt) = ERC721.owner_of(token_id); return (owner,); } @view func getApproved{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( token_id: Uint256 ) -> (approved: felt) { let (approved: felt) = ERC721.get_approved(token_id); return (approved,); } @view func isApprovedForAll{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( owner: felt, operator: felt ) -> (is_approved: felt) { let (is_approved: felt) = ERC721.is_approved_for_all(owner, operator); return (is_approved,); } // // Externals // @external func approve{pedersen_ptr: HashBuiltin*, syscall_ptr: felt*, range_check_ptr}( to: felt, token_id: Uint256 ) { ERC721.approve(to, token_id); return (); } @external func setApprovalForAll{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( operator: felt, approved: felt ) { ERC721.set_approval_for_all(operator, approved); return (); } @external func transferFrom{pedersen_ptr: HashBuiltin*, syscall_ptr: felt*, range_check_ptr}( _from: felt, to: felt, token_id: Uint256 ) { ERC721.transfer_from(_from, to, token_id); return (); } @external func safeTransferFrom{pedersen_ptr: HashBuiltin*, syscall_ptr: felt*, range_check_ptr}( _from: felt, to: felt, token_id: Uint256, data_len: felt, data: felt* ) { ERC721.safe_transfer_from(_from, to, token_id, data_len, data); return (); }