The contracts
directory provides interfaces and implementations of EIP token
standards. All payable methods are writen for minimal gas consumption.
Automated tests execute standalone with npx hardhat test
. Hardhat itself can
be obtained with npm install --save-dev hardhat
.
This is free and unencumbered software released into the public domain.
A FixedNFTSet
deployement costs 837 k gas.
Token transfers come in 3 variations.
- A plain
transferFrom
as the onwer of a token costs 49 k gas. - An
approve
costs 48 k gas, with another 48 k gas ontranferFrom
. - A
setApprovalForAll
costs 46 k gas, with another 49 k gas ontranferFrom
.
The NFTBuyout
contract is ready on the following chains. Please share when you
deploy on a chain not listed here.
Custom tokens can simply inherit the FixedNFTSet
contract.
It is recommended to import contracts with a versioned path only.
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.8.13;
import "https://github.com/pascaldekloe/enft/blob/v1.2.0/contracts/FixedNFTSet.sol";
// NFT example with 12 tokens.
contract MyDozen is FixedNFTSet {
// Constructor assigns all 12 tokens to the receiver address.
constructor(address receiver) FixedNFTSet(12, receiver) {
// initial Transfer emission is optional
for (uint token = 0; token < 12; token++) {
emit Transfer(address(0), receiver, token);
}
}
}
For a full NFT example with metadata and more, see CollectiblesSale on mainnet.
In a Node.js environment you can use the contracts in a project with
npm install https://github.com/pascaldekloe/enft.git
, and then import with
import "enft/contracts/ERC721.sol";
instead of the HTTP URL.
- “Token Standard” EIP-20
- “Non-Fungible Token Standard” EIP-721