Coder Social home page Coder Social logo

mintbase / mintbase-js Goto Github PK

View Code? Open in Web Editor NEW
63.0 10.0 21.0 21.41 MB

Powerful open-source library for doing all things NFTs on the NEAR protocol.

Home Page: https://docs.mintbase.xyz

License: MIT License

TypeScript 99.60% JavaScript 0.40%
blockchain typescript cryptocurrency wallet near mintbase

mintbase-js's Introduction

Mintbase JS

A library for making web3 end to end development as easy as possible from smart contract deployment and interaction to metadata storage and blockchain data access. Check our Templates repository for Mintbase.js

Start with a template

Check our Templates website, to bootstrap your dapp with mintbase.js with any of the currently 11 templates;

Status



@mintbase-js/auth:      
@mintbase-js/data:      
@mintbase-js/react:     
@mintbase-js/rpc:        
@mintbase-js/sdk:        
@mintbase-js/storage:
@mintbase-js/wallet:

{% hint style="danger" %}

All packages are currently in beta.

Breaking changes can and will be introduced on a regular basis until an official release later this year.

{% endhint %}

Getting started

For guides and specific use case examples visit our General Documentation

Specific Module Documentation

  • the mintbase wallet js sdk.
  • Deploy or interact with smart contracts and mintbase market
  • Add and manage wallet connection on your react dapp out of the box
  • Get blockchain data in a few lines of code
  • Upload metadata to permanent storage
  • near-api-js convenience wrappers for loading accounts and managing keys
  • Message singing and verification utils.

Join us in Building the Future

Have feedback or perhaps need a hand?

Reach out on our Telegram public developer support channel.

Building something cool?

Consider applying for a grant.

mintbase-js's People

Contributors

bh2smith avatar cif avatar jpcloureiro avatar jxnis avatar kujtimprenkusqa avatar microchipgnu avatar mintbaseteam avatar rubenmarcus avatar sainthiago avatar surgecode avatar tifrel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mintbase-js's Issues

Rate limit through NFT ownership

  • Map user wallet to NFT token
  • Generate an API key (may need to be updated)
  • For every request, check if API key -> NFT -> user (dev) wallet

Create a general Mintbase class

  • Re-org classes
  • Create Mintbase class. That will be init'd with external constants.
  • Instantiate wallet, api, minter, and any other module through this general class.

The goal of this is to allow using the different modules of Mintbase independently.

Add standalone minting method

This supports a future looking POC.

Looking to bypass the arweave.net upload workflow to enable use of simple/small SVGs media on-chain.

  • Add Wallet.mint_simple_nft method which bypasses the arweave requirements.

Merge batch and non-batch methods

Let's simplify the API by reducing the amount of methods that can for example list tokens in the marketplace to one. Similarly to how transfer works.

Mint method doesn't execute.

I bootstrapped my project from Mintbase Boilerplate and Starter for Next JS 12+, Tailwind CSS 3, and TypeScript.

The application successfully connects to a near wallet when the connect method is invoked, but when I call the
wallet.mint() nothing happens.

I implemented it in a previous version of the application and it worked but it doesn't seem to work on this recent project I'm working on.

What could be the issue?

Things to add

  • Util to extract token id from token key ("1:<contract_address>" => 1)

Arweave upload cloud function

This will allow to finish minting through mintbase.js

check omni-site components/Uploader.tsx to see how uploads are done

Fix queries

  • Fetch marketplace
  • Fetch token metadata
  • Fetch lists
  • Fetch store
  • Fetch thing
  • Fetch token
  • Fetch metadata
  • Fetch owner tokens
  • Fetch isOwner

Fix storage calcs

  • Remove 0.1 N fixed cost for list
  • Create calc for transfer
  • Create calc mint

Work is under storage-calc

Thor's explanation:

These are storage costs. Multiply them by 10^19 to get cost in Near.
Eg: if the cost is 440 bytes, it's 4.4 * 10^21 yoctoNear = 0.0044Near.

Mint:

First, you don't actually have to pay the whole cost at each mint. You DO have to pay ONE_YOCTO for a mint, but anything beyond that is unnecessary if you've already deposited enough onto the contract. This is because minting tokens is friggin complicated when in comes to gas costs, and only minters can call mint_tokens in any case.

This one's the most complicated. The size of the metadata AND the size of the royalty AND the size of the split owners can vary.

These costs are paid once, not per token:
100 bytes to create a record that the owner owns a new set of tokens
100 bytes or less, (usually! This can be as large as you want to make it in fact)
80 bytes for each royalty address.

These costs are paid for each token
80 bytes for each split address
360 bytes for the token

Supposing we mint N tokens with S splits, R royalties; this will fail if metadata is larger than expected:
100 + 100 + 80R + N(360 + 80S)
= 200 + 80
R + N*(360 + 80*S)

Approve (list):

Here, the complexity is that we have to accomodate the storage costs on both the Store and the Market.

Store:
80 bytes per approval

Market:
360 bytes per list

So 440 bytes per token approved.
=440*N

Transfer:

one yoctoⓝ

Improve error handling

Instead of throwing errors, return an object { data: any, error?: string }, for example.

Implementation should follow apollo lib design.

Store page throws an error, because of invalid payload in response

We minted programmatically an NFT (probably we did it in a different way or missed something) and it broke Mintbase UI:

https://testnet.mintbase.io/store/cryptokids.mintspace2.testnet
Returns «An unexpected error has occurred.»

{ "id": "q5LiLpH0QNJ2PojWl4lmUZ3zSss8hbtz--iBLCk5T_g:cryptokids.mintspace2.testnet", "metaId": "q5LiLpH0QNJ2PojWl4lmUZ3zSss8hbtz--iBLCk5T_g", "storeId": "cryptokids.mintspace2.testnet", "store": { "id": "cryptokids.mintspace2.testnet", "name": "cryptokids", "symbol": "crk", "owner": "deus.testnet", "__typename": "stores" }, "tokens": [], "__typename": "things" }

Steps to reproduce:

  • mint using mintbase-js from another app without specifying price and royalties
  • open your store page

Expected behavior
If the response contains an empty array of tokens, the app should handle it correctly and render the store page.

uploadFileToArweave does not work with Buffer

I'm uploading metadata to form as the reference for a mint. For example:

const metadata = Buffer.from(JSON.stringify({
    extra: "sample"
  }));
const response = await uploadFileToArweave(metadata, "sample-name");
const url = `https://arweave.net/${response.id}`;

If I run this, I will get the following exception, which is misleading because the actual exception being thrown does not work with httpError.response.text:

Cannot read properties of undefined (reading 'text')

The actual exception is:

Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'.

I think somebody just needs to wrap the buffer in "new Blob([buffer])". Wasn't caught because append function is mocked in test.

Optimize gas usage

  • Dynamically calculate gas usage for every call
  • Create a helper method for this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.