Berenu Profile picture
Apr 2 13 tweets 3 min read
¿Qué hace que un smart contract sea ERC-20? 👀

“Si un contrato inteligente implementa los siguientes métodos y eventos, se puede llamar un contrato ERC-20”

Abro hilo para explicar cada método y evento.

Dentro hilo! 😜

ethereum.org/es/developers/…

#SmartContracts #Ethereum
🔹 "function name() public view returns (string)"

Esta función nos devuelve el nombre del token. Por ejemplo: Dogecoin.
🔹 "function symbol() public view returns (string)"

Esta función nos devuelve el nombre corto del token. Por ejemplo: DOGE.
🔹 "function decimals() public view returns (uint8)"

Esta función nos devuelve el número de decimales del token. Si el token NO tiene decimales será 0. Curiosidad: Esto ocurre porque en Solidity no podemos poner números con decimales. Por eso nos toca jugar con números enteros.
🔹 "function totalSupply() public view returns (uint256)"

Esta función nos devuelve el total supply del token.
🔹 "function balanceOf(address _owner) public view returns (uint256 balance)"

Esta función nos devuelve el balance de una cuenta cualquiera.
🔹 "function transfer(address _to, uint256 _value) public returns (bool success)"

Es la responsable de enviar una cantidad X de tokens desde la cuenta que ejecute esta función a otra cuenta.

Aquí la gente que crea tokens ERC-20 puede implementar por ejemplo quemas en cada tx.
🔹 "function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)"

Esta función envia una cantidad "_value" de tokens desde la cuenta "_from" a una cuesta destino "_to"

Para que esta función se ejecute con éxito, el "_from" tiene que permitirlo
🔹 "function approve(address _spender, uint256 _value) public returns (bool success)"

La cuenta que ejecuta esta función le permite a otra cuenta "_spender" manejar una cantidad "_value" de tokens en su nombre.

Esta funcionalidad tiene mucha chicha 😜
🔹 "function allowance(address _owner, address _spender) public view returns (uint256 remaining)"

Esta función devuelve la cantidad de token que una cuenta (_owner_ le ha dado permiso para utilizar a otra cuenta (_spender).
🔹 "event Transfer(address indexed _from, address indexed _to, uint256 _value)"

Este evento se emite en las funciones que manejan los balances (transfer, _burn, _mint, ...)
🔹 "event Approval(address indexed _owner, address indexed _spender, uint256 _value)"

Este evento se emite en las funciones relacionadas con la funcionalidad de permitir a cuentas ajenas operar con nuestros tokens.
FIN DEL HILO! 😄 Si has llegado hasta aquí estás más cerca de ser un master del universo de contratos ERC-20.

Te gustaría que explicara más en detalle las funciones más interesantes en otro hilo? Pues dale cariñito 💙 o comparte ↪️

Sudosuberenu.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Berenu

Berenu Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(