Skip to content

To leverage AIGC technology with NFT, marketplace and privacy.

Notifications You must be signed in to change notification settings

artgo-labs/artgo

Repository files navigation

aigc.aleo program

The combination of AIGC and NFTs can create new digital content and value. The digital content generated by AIGC can be transformed into NFT — a unique digital asset with collecting and investment value.

For project introduction, please visit : Artgo Background.

For user guide, please visit : Artgo Tutorial.

Offical website : https://artgo.io/.

This documentation will introduce the program from technical side, keep updating.

Struct

struct Field2 {
    first: field,   // the first half
    second: field,  // the second half
}
struct NftHash {
    minter: address      // creator
    prompt: Field2,      // prompt command to generate image
    nonce: field,        // random number to unique nft
}
struct NftInfo {
    holder: address, // owner address
    minter: address, // minter address
    hash: filed,     // bhp256_hash(NftHash)
    uri: Field2,     // image content ipfs url
}
struct Order {
    holder: address, // owner address
    minter: address, // minter address
    nft_id: field,     // nft id
    order_type: u8,  // order type, 0:non-trading 1:normal 2:auction(Todo)
    amount: u64,    // minumum amount
    status: u8,      // order status, 0:non-trading 1:trading 2:canceled 3:finished
    deadline: field  // the timestamp to finish order -- blocknumber or timestamp
}
struct Bid {
    bidder: address,    // bidder address
    nft_id: field,        // id
    amount: u64,       // bidding amount
}
record BidRecord {
    bid_type: u8,        // 1-bid, 2-cancel
    owner: address,     
    bidder: address,
    nft_id: field,
    amount: field,
}
record Nft {
    owner: address,         // NFT owner
    minter: address,        // NFT minter
    prompt: Field2,          // NFT prompt, hidden
    nonce: field             // random number to unique nft
    uri: Field2,             // NFT content
}

Public states

tokenId

mapping Store the maximum tokenid.
tokenId store: bool => field;

nfts

mapping Store all the minted nfts.

nfts store: id => NftInfo
id id++ from 1

admin

mapping Store admin.
admin store: bool => address;

orders

mapping Store all the orders.
orders store: field => Order;
key: nft id

bids

mapping Store all the bids. bids store: field => Bid;
key: nft id

Interfaces

mint_nft

mint_nft used to mint nfts for aigc images nfts minted stored in Nfts

  • NFT mint, permisionless。

inputs:

  • prompt : Field2.private
    nft prompt

  • uri : Field2.public
    image content

  • nonce : field.public
    random unique number

outputs:

  • NFT record

usage:

run mint_nft:
leo run mint_nft
excute mint_nft:
snarkos developer execute -f $<fee> -r $<record> --query $<endpoint> --broadcast $<${endpoint}/testnet3/transaction/broadcast> -p $<private-key> $<program_id> ${function_id} $<inputs>
i.e:
snarkos developer execute 
-f 2509834 
-r "{  owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private,  microcredits: 93750000000000u64.private,  _nonce: 600042304734513817307279222414740026784347330221707613918989922910747206357group.public}" 
--query "http://localhost:3030" 
--broadcast "http://localhost:3030/testnet3/transaction/broadcast" 
-p "APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH" 
artgo_aigc_v1.aleo 
mint_nft "{
    first: 10000field,
    second: 10000field
}" "{
    first: 10000field,
    second: 10000field
}"
query nft:
i.e:
curl --location 'http://127.0.0.1:3030/testnet3/program/aigc.aleo/mapping/nfts/1field'

transfer_private_nft

transfer_private_nft used to tranfer nft.

  • transfer nft, permisionless.

inputs:

  • nft_id field
    NFT id

  • NFT record
    NFT to auction

  • receiver address
    Minimum amount for auction

outputs:

  • NFT record to receiver

usage:

TBD

place_order

place_order used to start an order.

  • place order, permisionless。

inputs:

  • nft_id field
    NFT id

  • NFT record
    NFT to auction

  • order_type order type
    0 - non-trading 1 - normal 2 - auction

  • amount field
    Minimum amount for auction

  • deadline field
    the timestamp to finish order

  • admin_in address
    admin address

outputs:

  • NFT record to admin

usage:

TBD

update_order

update_order used to update an order.'

  • update order, permisionless.

inputs:

  • nft_id : field
    nft id

  • new_amount : field
    order new amount

outputs:

usage:

TBD

cancel_order

cancel_order used to cancel an order.'

  • cancel order, permisionless.

inputs:

  • credit : Record
    Aleo Credit record

  • fee : u64
    cancel fee

  • nft_id : field
    nft id

  • admin_in address
    admin address

outputs:

  • BidRecord record

usage:

TBD

bid_order

bid_order to bid for NFT.

  • bid order, permisionless.

inputs:

  • credit : Record
    Aleo Credit record

  • nft_id : field
    nft hash

  • amount : field
    bid amount

  • admin_in address
    admin address

outputs:

  • BidRecord record

  • success --BidRecord record to admin, if amount greater than previous, refund the previous. Otherwise, tx will fail.

usage:

TBD

finish_order

finish_order to finish an order.

  • finish order, only admin
  • delete mapping when nft not sold.

inputs:

  • nft_id : field
    nft record

  • nft : NFT record
    nft record

  • fee : u64
    trading fee

  • winner : address
    winner address

  • winner_amount : field
    winner amount

  • admin_in : address
    admin address

outputs:

  • NFT record to winner

usage:

TBD

Workflow (TBD)

avatar

Build Guide

To compile this Aleo program, run:

leo build

Deploy Guide

To deploy this Aleo program, run:

i.e:
snarkos developer deploy 
--fee 1000001328000 
-r "{  owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private,  microcredits: 93750000000000u64.private,  _nonce: 878010960996471104548362432643577968735743754584843045001751072533354535962group.public}" 
--query "http://localhost:3030" 
--broadcast "http://localhost:3030/testnet3/transaction/broadcast" 
-p ${privatekey} 
artgo_aigc_v1.aleo
aigc program testnet3 deployed:

v1 deployed:
txid: at1gz5azfpd0xegxxnan9j9yy0fujghvtrfdqkad0gplwf95z38s5gqfvsvp4
curl --location 'http://testnet3.artgo.app/testnet3/program/artgo_aigc_v1.aleo'

v1_1 deployed:
txid: 
at148r6xq7dadmw3a0e0afnwl303xphy4qeuhhge54283kx7tsxtgzqzcpk9a
curl --location 'http://testnet3.artgo.app/testnet3/program/artgo_aigc_v1_1.aleo'

v1_2 deployed:
txid:
at1aencztkgs0rrw7z3p4nzkcxxgxrnnfqpwv43mf34n5f02j20vqgsqh77m7
curl --location 'http://testnet3.artgo.app/testnet3/program/artgo_aigc_v1_2.aleo'

v1_3 deployed:
txid:
at10538rm2ncpazklrkqgz29fq9dwc73f9wt5hpg9r3csfjqkzc4gzs7wrtr5
curl --location 'http://testnet3.artgo.app/testnet3/program/artgo_aigc_v1_3.aleo'

mapping query:

curl --location 'http://testnet3.artgo.app/testnet3/program/${program_name}/mapping/${mapping_name}/${key}'

About

To leverage AIGC technology with NFT, marketplace and privacy.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages