# Feral File v2.0 Minting Flow ###### tags: `Feral File` ## Goal - Support buying token on-chain. - Support distributing royalties of primary sale on-chain. ## Related Contract Code ```solidity 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 - [Feral File on 3rd party marketplaces metadata](/Y5aWIYLcReyxT1V5XfmBXg) ## 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 ```mermaid sequenceDiagram autonumber actor Operator Operator->>+FF BO: Request deploy contract FF BO->>FF BO: Validate contract data FF BO->>+FF Server: Call API to deploy contract FF Server->>FF Server: Validate contract data FF Server-)FF Background: Trigger workflow to deploy contract rect rgb(255, 255, 225) Note right of FF Background: Run asynchronously FF Background->>FF Background: Validate contract data FF Background-)+Vault: Call API to deploy contract Vault->>+Blockchain: Deploy contract Blockchain-->>Vault: Tx ID Vault-->>FF Background: Tx ID FF Background-)FF Background: Insert DB loop until tx is confirmed FF Background->>Blockchain: Get tx confirmation Blockchain-->>FF Background: Return tx confirmation end end FF Background-->>FF Server: Return workflow trigger result FF Server-->>FF BO: Return workflow trigger result loop until have contract DB record FF BO->>FF Server: Call API to get contract DB record FF Server-->>FF BO: Return result end FF BO-->>Operator: Return success/failure ``` ## 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) ```go part1 := contractAddress part2 := decToHex(1000000 * seriesIndex + tokenIndex) // assume every series has maximum amount of token is 1000000 tokenID := hexToDec(part1 + part2) // literally concatenate ``` ### Flow ```mermaid sequenceDiagram autonumber actor Operator Operator->>+FF BO: Request to mint exhibition FF BO->>FF BO: Validate exhibition data FF BO->>FF Server: Call API to mint exhibition FF Server->>FF Server: Validate exhibition data FF Server-)FF Background: Trigger workflow to mint tokens rect rgb(255, 255, 225) Note right of FF Background: Run asynchronously FF Background->>FF Background: Validate exhibition data FF Background->>FF Background: Prepare token data FF Background->>Vault: Call API to execute contract call Vault-->>FF Background: Tx ID loop until tx is confirmed FF Background->>+Blockchain: Get tx confirmation Blockchain-->FF Background: Return tx confirmation end FF Background->>FF Background: Insert DB end FF Background-->>FF Server: Return trigger result (Workflow/Run ID) FF Server-->>FF BO: Return trigger result (Workflow/Run ID) loop until workflow run is completed/failed FF BO->>FF Server: Get workflow run state FF Server-->>FF BO: Return workflow run state end FF BO-->>Operator: Return success/failure ``` ## APIs ### Vault - No ### Feral File - BO API to trigger the workflow to deploy the contract - BO API to get the deploy contract workflow state