PolyBlocks β

MENU

Learn about PolyBlocks


OVERALL SCHEME

ARTWORK

PolyBlocks allows anyone to create works of art freely. Up to 10000 tokens can be minted from each artwork.

Once an artwork is minted, it is posted on PolyBlocks where collectors can mint (purchase) tokens from it.

TOKENS

Once a collector purchases one token from an artwork, an NFT (ERC-721 token) is minted.

The tokens are also exchangeable on other NFT marketplaces such as OpenSea!

overall scheme

STEP 1. Select an external library

PolyBlocks allows artists to use one external library at most. p5.js, threejs and SVG.js are currently available.

If you prefer full scratch, you can of course choose no dependencies.

STEP 2. Write some JavaScript

There are several rules as follows:

  • You need to choose a hash which will be used when your artwork appears on PolyBlocks. Please take a good hash to make your work more attractive!
  • A different hash will be given to each token of that artwork, with which all the tokens can be differentiated.
  • The hash can be accessed with the pb.hash variable.
  • Use sfc32-based pb.random() instead of Math.random() to feed a randomness determined by the hash given to each token.
  • The script should be less than 50kb otherwise you cannot store it on chain.
  • See a full html template here for your creation!

Randomness

We embed a JavaScript object called “pb”.

  • pb.hash to get a unique hash value which determines the output of random functions below.
  • pb.random() to get random values (0 to 1)
  • pb.randrange(a, b) to get a random number between two values (a < r < b).
  • pb.randint(a, b) to get a random integer between two values (a <= r <= b).
console.log(pb.hash) // returns a hash string

console.log(pb.random()) // returns a random values between 0 and 1

console.log(pb.randrange(0, 3)) // returns a random values between 0 and 3

console.log(pb.randint(0, 3)) // returns either 0, 1, 2, or 3

PolyBlocks strongly recommends that all artists use those random functions to feed all of their project's randomness. They're all based on the sft32 algorithm.

All the attributes of your piece should be derived from that hash so that users will be able to render the piece on their token and get the same results each time.

Attributes

Attributes can be given to each token through pb.attributes.

  • The values must be either `string`, `number` or `boolean`.
  • pb.attributes must be defined once the page is loaded.
  • Continuous numbers are not recommended because the rarity is calcucated through counting the number of exact occurences.
const seed = pb.random();

function getRarity(seed) {
  if (seed < 0.05) { return 'Legendary' }
  else if (seed < 0.15) { return 'Epic' }
  else if (seed < 0.3) { return 'Rare' }
  else { return 'Common' }
}

function ageAge(seed) { return Math.floor(seed * 10) }

function getIsHunam(seed) { return seed < 0.5 }

pb.attributes = {
  'rarity': getRarity(seed), // string
  'age': ageAge(seed), // numerical
  'isHuman': getIsHunam(seed) // boolean
}

STEP 3. Capture a thumbnail

Select a time before the capture is taken. This is useful to capture the best moment if your artwork is an ever-changing piece.

STEP 4. Write metadata

This is the last step! You can fill in metadata such as the title, description, and price of the tokens.

Connect