CAVYAR

CAVYAR AI

Minting NFT in Solana using Flutter

nft
flutter
minting
json

1. Make Metadata: _uploadJson is async, allowing calls on execution. Creates a map of the attributes: name: from the nameController.text. symbol: from the symbolController.text. description: from the descriptionController.text. image: imageUrl prefixed by IPFS URL. attributes: null but, can hold properties. properties: creators: null but can hold creator info. files: single entry with: type: assuming the uploaded file is a PNG. uri: from imageUrl. collection: map converted to JSON. 2. Upload to IPFS: temp_dir from by getTemporaryDirectory. File named after NFT created in dir. JSON written using file.writeAsString. uploadToIPFS called async to upload to IPFS. uploadToIPFS return CID of file on success, or null on not. 3. Upload Result: If uploadJsonResult CID isn't null: cid is assigned the uploaded file's CID. App state reset: _jsonUploaded set true, indicating successful upload. _mintingNft true, indicating the mint is starting. _createNft called to create NFT on Solana by metadata

_uploadJson() async { Map<String, dynamic> data = { 'name': nameController.text, 'symbol': symbolController.text, 'description': descriptionController.text, 'image': 'https://quicknode.myfilebase.com/ipfs/$imageUrl', "attributes": [], "properties": { "creators": [], "files": [ {"type": "image/png", "uri": "ipfs://$imageUrl/"} ] }, "collection": {} }; String json = jsonEncode(data); final directory = await getTemporaryDirectory(); final file = File('${directory.path}/${nameController.text}.json'); await file.writeAsString(json); final uploadJsonResult = await uploadToIPFS(file); if (uploadJsonResult != null) { cid = uploadJsonResult; setState(() { _jsonUploaded = true; _mintingNft = true; }); _createNft(); } }

CAVYAR AI

CAVYAR AI is in its earliest stages of development and the quality of generated descriptions will improve massively over time. At this stage, there is a risk of false information being generated.

I'm tuned to only answer questions about the Anchor framework, web3.js, or Rust Solana smart contracts. Your question seems to be related to Flutter and its interaction with IPFS for NFT minting, which falls outside my expertise area.

Ask

Soon™

Created by:

ApeG...NrWy

Give this snippet a feedback!

Published on

September 19, 2024

Want to support the author?