New Rich on the Block - Technical review
New Rich on the Block
website: http://newrichontheblock.com
Technical review. This publication is a technical appendix of this post.
How does it work?
New Rich on the Block is a small project that aims to maintain a ranking of the richest people in the Ethereum blockchain. To participate, users can pay up to 10% of their wealth in any of the ERC20 Tokens on Ethereum and occupy a position in the ranking of that currency.
When registering, the user will have to fill out a form where they can upload a photo, write a title and a text to share. Each record will be permanently stored in blockchain and can be consulted by anybody.
DApp Architecture
The entire DApp consists of three fundamental parts:
- Front end (html5) & Metamask (web3.js):
When you build a html5 front end for an Ethereum DApp you will be working with web3.js. This is a library that implements an API to communicate with Ethereum blockchain. You can use this library to extract or push data directly on the blockchain, or you can to create an abstract javascript objects to interact with a specific smart contract on Ethereum.
To create those objects you need to provide the contract address along with the ABI json that describes the contract API. All that can be obtained using remix which is an online Solidity Editor.
Metamask a is browser extension that brings an interface to the user to interact with Ethereum. Also, when present, this extension injects a service provider that can be used along with web3.js as proxy from the website. This way you don't need to set up a backend to connect from there to the blockchain.
- Ethereum (Smart Contracts)
This project started as a simple "hello, world" but quickly was getting more and more complexity till I reached a point where I have to split the logic in modules, no only for the sake of quality but because a smart contract siply can not be very big.
So I split my logic in three smart contracts:
- NRB_Main
This is the main contract which is in charge of receiving all the requests and delegating the job. It also stores the raised amount for every token.
- NRB_Tokens
This contract stores the info of all the tokens that where registered. The first intention was having stored the USD price for a given time for every currency but that required a transaction for each pair price-datetime and therefore some money cost. So I decided to let this logic outside the contract losing some of the magic of original idea.
- NRB_Users
This contract stores all the info introduced in the form. My first try was to store the picture inside the form text in base64 format. I only worked with small pictures and even in those cases a lot of many was needed. So I decided to store de picture in the server and store the link in the smart contract. Back then I wasn't aware of the IPFS protocol which is the solution for this problem.
- NRB_Main
- Backend (php and mysql)
Not always the Metamask extension is present in all the browser, therefore I had to have some fallback in a backend for servig the same information as you were using the extension. That's why a backend was needed.
Working with ERC20
When you send ERC20 tokens to someone you don't send a transaction to that person's address. Instead you have to send a transaction to the smart contract implmenting that Token, and specify the address destination along with the amount you wanna send. Therefore, the smart contract receives a transaction signed by you, the owner of the tokens to be transfered, so the operation can be done directly.
However, when you are consuming a service from a smart contract and you have to pay with ERC20 Tokens, you will have to send two transactions. The first one goes to the Token's contract to to approve the debit from the app. The second one is requested by the app once you consume the service.
References:
Demasiado buen ride esto. lml keep it up!
Te presento mi proyecto, Cards & Tokens
https://steemit.com/introduceyourself/@viterbo/introducing-cards-and-tokens
Me encantaría saber tu opinión.
Pregunta , el ABI es el API del contrato , y web3 es el API de eth, entre las dos negocian los RPCs del business logic? es Asi ?. todavia stoy entendiendo la estructura y el ABI.
El project sta fino ,un crypto kitties pero mas custom, que interesante que se considere como un unique cryptocurrency cada carta digital , como determina eso? , es un ERC20 con add on para que cada carta digital, tenga un unique signature. Esta cacheton. Sobre los tokens no me queda claro,Los primeros dos si, uno es para local market y el otro utility. No entendi para que era vapanee (verde ) y el golden. Y con solo tener EOS , le puede caer un airdrop de los 4 tokens de BG games? Igual iba a comprar EOS pero tambien se pone fuzzy todo cuando EOS se salga del eth blockchain. que loquera mas tuanis.
Mucha info en una sola respuesta. Espero no abrumarte!
ABI: el abi es un json que describo el API que tiene el contrato inteligente. Desde tu sitio web utilizas el web3js para instanciar un objeto javascript que te servirá de proxy. Ese objeto lo creas utilizando el ABI y la dirección del contrato sobre la blockchain.
Cards & Tokens: la propuesta es que cualquier creador de contenido pueda subir sus archivos y con ellos crear una publicación quemo si se tratara de una publicación en Steem pero usando el nuevo formato Carta Digital Coleccionable. Una vez hecha la publicación (o carta), el creador deberá definir cuantas copias quiere que existan de esa carta (eso está limitado al nivel de usuario que tenga). Una vez creadas las copias, éstas se pueden vender, subastar o regalar. En ese sentido una copia de una carta es como una unidad de una currency. Dicho de otra manera, cada publicación se transforma en una especie de crypto moneda de la cual existen pocas unidades y cada unidad es indivisible.
el ERC20 no alcanza para desribir éste tipo de Assets. En su lugar estamos evaluando alguna variante del ERC875 para non fungible tokens
4 Tokens:
La idea de ofrecer un paquete de Tokens en la preventa (en vez de un solo Token) es motivar a los primeros inversores. Recién estamos comenzando y no tenemos demasiado para ofrecer, más que Tokens futuros. Esa es la razón principal.
Zero todobien ud suelta puro probono, lo bonito esta en los detalles.
Con razon cryptokitties colapso la hostia, tiene que pagar gas por cada tx y solo puede una a la vez, y si las txs de erc875 son offchain , quien procesa esas acciones, donde sucede that computation?(corregir o cancelar el bid), donde se sostiene ese data(IPFS?)? .
Algo que no me queda claro, eth es PoW y va a pasar a PoS pronto con el protocolo casper? Staba aprendiendo como funcionaba el protocolo bitcoin pero siento como que ethereum me esta llamando XD.
Voy a leer mas para preguntar menos.. xD
This post has received a 3.36 % upvote from @boomerang.
This post has received votes totaling more than $50.00 from the following pay for vote services:
appreciator upvote in the amount of $28.63 STU, $48.32 USD.
smartsteem upvote in the amount of $21.04 STU, $35.51 USD.
boomerang upvote in the amount of $2.94 STU, $4.97 USD.
pushup upvote in the amount of $0.96 STU, $1.62 USD.
mercurybot upvote in the amount of $0.91 STU, $1.54 USD.
For a total calculated value of $54 STU, $92 USD before curation, with approx. $14 USD curation being earned by the paid voters.
This information is being presented in the interest of transparency on our platform and is by no means a judgement as to the quality of this post.