Try   HackMD

Feral File v2.0 Minting Flow

tags: Feral File

Goal

  • Support buying token on-chain.
  • Support distributing royalties of primary sale on-chain.
struct Artwork {
    uint256 id
    uint256 seriesIndex
    string ipfsCID
}

struct MintData {
    uint256 tokenID
    uint256 seriesIndex
    address minter
    string  ipfsCID
}

address private _signer;

bool private _burnable;

bool private _bridgeable;

string private _tokenBaseURI;

string private _contractURI;

// Total suplies
mapping(uint256 => uint256) internal seriesMaxSupplyMap; // index => max supply

constructor(
    string memory name_,
    string memory symbol_,
    string memory contractURI_,
    string memory tokenBaseURI_,
    address memory signer_,
    bool burnable_,
    bool bridgeable_,
    uint256[] memory _seriesMaxSuplies, // indexed max supply based on series index
) ERC721(name_, symbol_) {
    // Add some validations
    // _seriesMaxSuplies.length > 0
    // ...
    
    _signer = signer_;
    _burnable = burnable_;
    _bridgeable = bridgeable_;
    _tokenBaseURI = tokenBaseURI_;
    _contractURI = contractURI_;
    
    // Initialize total supply map
    for (uint256 i = 0; i <_seriesMaxSuplies.length; i++) {
        seriesMaxSupplyMap[i] = _seriesMaxSuplies[i]
    }
}

function mint(MintData[] memory data) 
    external 
    onlyAuthorized {
        for (uint256 i = 0; i< data.length; i++) {
            _mint(data[i].seriesIndex,
                  data[i].tokenID,
                  data[i].ipfsCID,
                  data[i].minter);
        }
}

function _mint(uint256 _seriesIndex, 
               uint256 _tokenID, 
               string memory _ipfsCID, 
               address memory _minter) private {
    // TODO
}

function buy(uint256[] memory _tokenIDs,
             uint256 _price,
             uint256 _expiryTime,
             map[address]uint256 memory _royalties,
             bytes32 _r,
             bytes32 _s,
             uint8 _v) 
    external 
    payable
{
    // TODO
}

Token Metadata

Deployment Note

  • Remove AE, PP restriction, only maintain max supply for every series from contract side.
  • Contract configuration will be set by the contract deployment. E.g. royalty settings, max supply, signer (support for buying token onchain, )
  • Leverage the vault API to deploy new contract.

Flow

BlockchainVaultFF BackgroundFF ServerFF BOBlockchainVaultFF BackgroundFF ServerFF BORun asynchronouslyloop[until tx is confirmed]loop[until have contract DB record]OperatorRequest deploy contract1Validate contract data2Call API to deploy contract3Validate contract data4Trigger workflow to deploy contract5Validate contract data6Call API to deploy contract7Deploy contract8Tx ID9Tx ID10Insert DB11Get tx confirmation12Return tx confirmation13Return workflow trigger result14Return workflow trigger result15Call API to get contract DB record16Return result17Return success/failure18Operator

Minting Note

  • Mint token directly to the contract, DON'T need to mint to artist vault address.
  • Mint token directly to artists for trading between artists in an exhibition.
  • Using index as series identifier from contract side based on the database column featuring_index as long as it's unique in contract.
  • tokenID derived from the contract address and series index and ensure the uniqueness among the whole system (no matter contract)
part1 := contractAddress
part2 := decToHex(1000000 * seriesIndex + tokenIndex) // assume every series has maximum amount of token is 1000000
tokenID := hexToDec(part1 + part2) // literally concatenate

Flow

Syntax error in textmermaid version 11.6.0

APIs

Vault

  • No

Feral File

  • BO API to trigger the workflow to deploy the contract
  • BO API to get the deploy contract workflow state