da0 arm0ry on Notion
M I S S I O N S T A T E M E N T da0 arm0ry (”武器房”) 是一個 Web3 實驗場域:
``` // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.4; /// @notice Safe ETH and ERC-20 transfer library that gracefully handles missing return values /// @author Modified from Solmate (<https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol>) /// License-Identifier: AGPL-3.0-only library SafeTransferLib { /// ----------------------------------------------------------------------- /// Errors /// ----------------------------------------------------------------------- error ETHtransferFailed(); error TransferFailed(); error TransferFromFailed(); /// ----------------------------------------------------------------------- /// ETH Logic /// ----------------------------------------------------------------------- function _safeTransferETH(address to, uint256 amount) internal { bool success; assembly { // transfer the ETH and store if it succeeded or not success := call(gas(), to, amount, 0, 0, 0, 0) } if (!success) revert ETHtransferFailed(); } /// ----------------------------------------------------------------------- /// ERC-20 Logic /// ----------------------------------------------------------------------- function _safeTransfer( address token, address to, uint256 amount ) internal { bool success; assembly { // we'll write our calldata to this slot below, but restore it later let memPointer := mload(0x40) // write the abi-encoded calldata into memory, beginning with the function selector mstore(0, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(4, to) // append the 'to' argument mstore(36, amount) // append the 'amount' argument success := and( // set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // we use 68 because that's the total length of our calldata (4 + 32 * 2) // - counterintuitively, this call() must be positioned after the or() in the // surrounding and() because and() evaluates its arguments from right to left call(gas(), token, 0, 0, 68, 0, 32) ) mstore(0x60, 0) // restore the zero slot to zero mstore(0x40, memPointer) // restore the memPointer } if (!success) revert TransferFailed(); } function _safeTransferFrom( address token, address from, address to, uint256 amount ) internal { bool success; assembly { // we'll write our calldata to this slot below, but restore it later let memPointer := mload(0x40) // write the abi-encoded calldata into memory, beginning with the function selector mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(4, from) // append the 'from' argument mstore(36, to) // append the 'to' argument mstore(68, amount) // append the 'amount' argument success := and( // set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // we use 100 because that's the total length of our calldata (4 + 32 * 3) // - counterintuitively, this call() must be positioned after the or() in the // surrounding and() because and() evaluates its arguments from right to left call(gas(), token, 0, 0, 100, 0, 32) ) mstore(0x60, 0) // restore the zero slot to zero mstore(0x40, memPointer) // restore the memPointer } if (!success) revert TransferFromFailed(); } } /// @notice Modern, minimalist, and gas efficient ERC-721 implementation. /// @author Solmate (<https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol>) /// @dev Note that balanceOf does not revert if passed the zero address, in defiance of the ERC. abstract contract ERC721 { /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 indexed id); event Approval(address indexed owner, address indexed spender, uint256 indexed id); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /*/////////////////////////////////////////////////////////////// METADATA STORAGE/LOGIC //////////////////////////////////////////////////////////////*/ string public name; string public symbol; function tokenURI(uint256 id) public view virtual returns (string memory); /*/////////////////////////////////////////////////////////////// ERC721 STORAGE //////////////////////////////////////////////////////////////*/ mapping(address => uint256) public balanceOf; mapping(uint256 => address) public ownerOf; mapping(uint256 => address) public getApproved; mapping(address => mapping(address => bool)) public isApprovedForAll; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor(string memory _name, string memory _symbol) { name = _name; symbol = _symbol; } /*/////////////////////////////////////////////////////////////// ERC721 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 id) public virtual { address owner = ownerOf[id]; require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED"); getApproved[id] = spender; emit Approval(owner, spender, id); } function setApprovalForAll(address operator, bool approved) public virtual { isApprovedForAll[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function transferFrom( address from, address to, uint256 id ) public virtual { require(from == ownerOf[id], "WRONG_FROM"); require(to != address(0), "INVALID_RECIPIENT"); require( msg.sender == from || msg.sender == getApproved[id] || isApprovedForAll[from][msg.sender], "NOT_AUTHORIZED" ); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. unchecked { balanceOf[from]--; balanceOf[to]++; } ownerOf[id] = to; delete getApproved[id]; emit Transfer(from, to, id); } function safeTransferFrom( address from, address to, uint256 id ) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } function safeTransferFrom( address from, address to, uint256 id, bytes memory data ) public virtual { transferFrom(from, to, id); …
LooksRare
Default Anchor Certificate #1 - arm0ry | LooksRare
Anchor City Certificate
HackMD
# da0 arm0ry 第九次會議 :::info **日期:** Jan. 19, 2023 **開會時間**: 台灣時間週四 10pm / 紐約時間週四 9 am **會議流程**:
app.kali.gg
Create or vote on a proposal.