All Projects → TENK-DAO → tenk

TENK-DAO / tenk

Licence: LGPL-3.0 License
Template for making a NFT contract with a raffle of tokens

Programming Languages

typescript
32286 projects
rust
11053 projects
SCSS
7915 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects
shell
77523 projects

Projects that are alternatives of or similar to tenk

nft-website
NFT School: Community education platform for developers in the non-fungible token space.
Stars: ✭ 260 (+712.5%)
Mutual labels:  ipfs, nft
nft-art-maker
NFT Art Maker - generates images and metadata files, packs them into IPFS CAR files, and uploads them using nft.storage. All from provided PNG layers.
Stars: ✭ 77 (+140.63%)
Mutual labels:  ipfs, nft
nft.storage
😋 Free decentralized storage and bandwidth for NFTs on IPFS and Filecoin.
Stars: ✭ 309 (+865.63%)
Mutual labels:  ipfs, nft
nftool
A suite of tools for NFT generative art.
Stars: ✭ 145 (+353.13%)
Mutual labels:  ipfs, nft
apebase
Bored Ape Database
Stars: ✭ 110 (+243.75%)
Mutual labels:  ipfs, nft
kotal
Blockchain Kubernetes Operator
Stars: ✭ 137 (+328.13%)
Mutual labels:  ipfs, near
ipfs-docs
📚IPFS documentation platform
Stars: ✭ 196 (+512.5%)
Mutual labels:  ipfs
subsocial-offchain
Off-chain storage for Subsocial blockchain. This app builds user feeds and notifications by subscribing to Substrate events.
Stars: ✭ 24 (-25%)
Mutual labels:  ipfs
awesome-orbitdb
Useful resources for using OrbitDB and building projects on it
Stars: ✭ 87 (+171.88%)
Mutual labels:  ipfs
dlux open token
DLUX distributed deterministic finite state automata. Built for HIVE to take advantage of free transactions using multi-sig and escrow for security.
Stars: ✭ 16 (-50%)
Mutual labels:  ipfs
go-libp2p-tor-transport
🚧 WIP: tor transport for libp2p
Stars: ✭ 41 (+28.13%)
Mutual labels:  ipfs
DTrip
DTrip - Traveler's app on STEEM blockchain.
Stars: ✭ 18 (-43.75%)
Mutual labels:  ipfs
pinning-services-api-spec
New vendor-agnostic Pinning Service API for IPFS ecosystem
Stars: ✭ 48 (+50%)
Mutual labels:  ipfs
RabbitMQ-with-Django
Example for using Microservices with RabbitMQ in a Django Web-Application
Stars: ✭ 26 (-18.75%)
Mutual labels:  ipfs
lootloose.com
LootLoose lets you unbundle your Loot Bags into individual item NFTs or rebundle items into their original Loot Bags.
Stars: ✭ 33 (+3.13%)
Mutual labels:  nft
svgnft
Making it slightly easier to create fully on-chain SVG-based NFTs.
Stars: ✭ 44 (+37.5%)
Mutual labels:  nft
pacman.store
Pacman Mirror via IPFS for ArchLinux, Endeavouros and Manjaro
Stars: ✭ 65 (+103.13%)
Mutual labels:  ipfs
godless
Peer-to-peer lite database over IPFS
Stars: ✭ 72 (+125%)
Mutual labels:  ipfs
hyperledger
Blockchain、Hyperledger、Ethereum、IPFS learning materials / 学习指南
Stars: ✭ 93 (+190.63%)
Mutual labels:  ipfs
meanOs
Mean Operating System - The first decentralized, artificially intelligent, MEAN.js stack, operating system. Mean OS is the only operating system hosted anonymous using a P2P network and a suite of non-standard in-browser delivery mechanisms. Mean OS proudly supports Brave and Tor, be free!
Stars: ✭ 62 (+93.75%)
Mutual labels:  ipfs

Tenk NFT

This contract publishes collections of NFT for example 10,000, hence TenK. Each time a token is minted it is randomly chosen from the remaining tokens. The core mechanism for this is a Raffle collection type, which allows randomly picking from a range without replacement. This contract also introduces the idea of using a linkdrop proxy to allow the owner or a normal user to "pre-mint" an item.

Details

Each token_id is numbered in a range, e.g. 0-10,000. This each asset and its metadata then named correspondingly, e.g. 0.png, 0.json. These files are placed into a flat directory and added to IPFS. This hash is used as the base_uri for the contract and all minted token_id can be used to find its corresponding file.

For example,

Linkdrop proxy

Currently this project wraps its own linkdrop-proxy, but in the future it this will be its own contract that any contract use for the same ability to add a callback to be used when the linkdrop is claimed. When a linkdrop is created it reserves a raffle draw to be made when claiming. This allows the token to be a surprise (unless it's the last one).

API

TypeScript docs are found at https://tenk-dao.github.io/tenk/docs.

Currently there is no standard format to describe the types of a contract. One proposal is to use the wit format, which while intended as a tool to generate bindings that act as polyfill for WebAssembly Interface Types, it provides a language agnostic way to describe types for the API of a Wasm Binary.

This work has led to the creation of witme, a tool for both generating a .wit document describing a Rust smart contract and generating a TypeScript file from a .wit document. The generated TS file also includes a Contract class which handles calling the corresponding methods.

For example, nft_transfer generates the following three functions:

// Will throw if there is an error and parse result if it exist.
nft_transfer(args: {
    receiver_id: AccountId;
    token_id: TokenId;
    approval_id?: u64;
    memo?: string;
}, options?: ChangeMethodOptions): Promise<void>;

// Will return the response from the server regardless of it succeeded
nft_transferRaw(args: {
    receiver_id: AccountId;
    token_id: TokenId;
    approval_id?: u64;
    memo?: string;
}, options?: ChangeMethodOptions): Promise<providers.FinalExecutionOutcome>;

// Creates a function call action that can be added to a transaction
// See the `./scripts/deploy.ts` for how this can be used
nft_transferTx(args: {
    receiver_id: AccountId;
    token_id: TokenId;
    approval_id?: u64;
    memo?: string;
}, options?: ChangeMethodOptions): transactions.Action;

Having the types mean that your contract calls will be type checked and prevent failed transactions from missing or malformed arguments.

View calls also generate a function.

/// makes a view call and parses the result
nft_payout(args: {
    token_id: string;
    balance: U128;
    max_len_payout?: number;
}, options?: ViewFunctionOptions): Promise<Payout>;

nft_token(args: { token_id: TokenId;}, options?: ViewFunctionOptions): Promise<Token | null>;

Using the contract's types

The main file and types of this package are found ./contracts/tenk/dist/* and specified in the package.json. These

From another TS project:

import { Contract } from "tenk-nft"

...


async function main({account}) {
  const contract = new Contract(account, "tenkv0.testnet.tenk");

  await contract.nft_transfer({receiver_id: "eve.testnet", token_id: "0"});
  const token = await contract.nft_token({token_id: "0"})
  console.log(`token ${token}`);
}

Using scripts with near-cli

A recent update to near-cli allows passing a script the current context of the current near environment. This includes the account that is signing the transactions, access to the same near-api-js that the cli is using, and an array of arguments passed to the script.

For example, from the script update_royalties.ts:

import {Context} from "near-cli/context";
import {Contract} from "..";

export async function main({ account, argv }: Context) {
  let [contractId] = argv;
  if (contractId === null) {
    console.error("need to supply contract's accountId")
    console.error("... -- <contractId>")
  }
  let contract = new Contract(account, contractId);
  const royalties = {
    percent: 690,
    accounts: {
      "tenk.sputnik-dao.near": 2500,
      "bob.near": 7500,
    }
  };
  let res = await contract.update_royalties({ royalties });
}

Run the script with near-cil's repl command using the option -s to pass a script. Other arguments of near-cli can be passed and any arguments after the -- are collected in the passed argv.

near repl -s ./scripts/update_royalties.ts --accountId owner.testnet -- contract.testnet

This makes it easy to create your own near scripts, while still getting the benefit of type checking parameters.

Uploading Assets with nft-cli

  1. Have NFT_STORAGE_API_TOKEN env var set to api key from https://nft.storage
  2. Have assets numbered 0-x with matching names 0.png 0.json in all in the same directory. E.g. dir/0.png dir/0.json.
  3. Install nft-cli: npm install -g nft-cli
  4. Pack assets with nft pack dir --output nfts.car
  5. Upload to nft.storage with nft upload nfts.car. Optionaly can pass api token with --api-key

Aspects of Near that prevents hacks on this method of minting

Here is one example of a "hack" that stole $85 million worth of nfts minted in a similar fasion. The "attacker" was able to map the NFT's id (our index) to its worth (its rarity). Then made a contract that made a cross contract call to mint an NFT, then canceling the transaction if it's not rare enough. Though this cost the "attacker" $20K fees per hour, they were able to see the rare items and reap the reward.

The key aspect that this hack and others like it on Ethereum rely on is that a series of cross contract calls either succeed or fail. This way you can opt out of it before the end and goods never change hands. On Near this is not the case. Each cross contract call is asynchronous and can change the state. This means when you use a cross contract call to mint a token and it succeeds, any money spent is gone and the token minted. Thus unlike the Ethereum example if you aren't satisfied with the token you received you can't choose to not receive it and not pay the owner.

NFT Standards

For more information about the API provided by the NFT standard see nomicon.io.

Development

This project also aims to highlight the newest way to test smart contracts on near using near-workspaces. See example tests in __test__.

Node must be installed. And Rust must be install see Getting Started in near-sdk.io.

To build docs witme must be installed.

cargo install witme
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].