Inspiration
Everything started by taking a look at Avataaars open source design library. There are thousands of combinations that can be made in order to create your own avatar.
Using that principle, I designed a system that allows you to play by generating random Avataaars using an ERC721 token to represent them using a randomly DNA calculated with Chainlink VRF
What it does
It uses an algorithm to determine characteristics of the avataaar based on there main parameters:
- The address of the user
- A random variable held in the contract and refreshed on every submission using the ChainLinks VRF
- The name of the new avatar
You can write a name, and you will always get a different Avataaar, so you can only buy one until you're comfortable to do it
How I built it
I used the VRF service of ChainLink's oracle in a ERC721 token deployed on Ethereum testnet. It is also fully compliant with ERC721, so it can more features in future development.
Basically, the way the Avataaar looks is based on an algorithm that takes every single variant of the Avataaar and combines it to generate a unique version of it, which is expressed as parameters to call to the public REST API they have, giving a dynamic SVG generation for every new avatheeer created.
This is the algorithm given the generated DNA:
/**
* Creates an src for a custom avataaar using its API
* to construct visual representation of the DNA
*
* @param {string} dna Unique identifier
*/
generateAvatheeerSrc = (dna) => {
let src = 'https://avataaars.io/?avatarStyle=Circle&';
Object.keys(dnaVariants).forEach((key, index) => {
const element =
dna.substring(index * 2, (index + 1) * 2) % dnaVariants[key].length;
src += `${key}=${dnaVariants[key][element]}&`;
});
return src;
};
Challenges I ran into
It was so difficult to build the DNA system, and also, integrating the oracle into the Avatheeer workflow. There are still some problems with the visualization of the Avataaar, since the random value is always changing with every new transaction, I was not able to solve that problem, but may be improved in the future.
Accomplishments that I'm proud of
I developed a complete ERC721, which means that it can also be used for many other things than the frontend app functionality.
Also, the app is deployed on ipfs, so you can access it by going to IPFS with the hash QmNSNRWnEdtC1q2H1QmGHeTKbSNX79ubKssGJhs7XiDdLK
What I learned
I've never used ChainLink before, so I got used to their services, and aside from that, I got experience on deploying a website to IPFS
What's next for Avatheeers
It may be developed in many different ways since it is ERC721 compliant, so it can be extended to as many functionalities as for example, CryptoKitties have.
Built With
- chanlink
- ethereum
- infura
- javascript
- vanilla
- web3

Log in or sign up for Devpost to join the conversation.