Giter VIP home page Giter VIP logo

wrapped-aergo's Introduction

WAERGO

The "wrapped AERGO" token is the ARC1 version of the native AERGO token

Name:wrapped AERGO
Symbol:WAERGO
Decimals:18
Address (testnet):AmgH9yTTiU4jXANgBzpskHuziaVRDU8LYHRh99azojR5eGVRVX6B
Address (alphanet):Amhe3APBtSWKLvfMnjycXCcugQnoaysmnKywzDLDkwwUdoFwvWu6

With this contract we can "convert" native AERGO tokens to its "wrapped" version (WAERGO) in ARC1 format, as well as to convert back the wrapped tokens to the native ones (unwrap)

It makes it easier to develop DeFi contracts, as they only need to support ARC1 tokens

Wrapping and Unwrapping

Soon we may have apps to make the conversion easy, and signing via the Aergo Connect

Probably the token swap apps will support the conversion

Sometimes the conversion will be automatic so we will not even perceive

Using the contract (for developers)

On the examples bellow we consider that waergo is a variable containing the address of the WAERGO contract.

For use in the console:

export waergo=Am...

The address depends on the network being used.

Wrap

Call the wrap function, sending the aergo tokens that should be wrapped.

On a contract:

contract.call.value(amount)(waergo, "wrap")

Your contract must implement the tokensReceived() function, that will be called with details of the token conversion.

Example:

function tokensReceived(operator, from, amount)
  ...
end

Wrap To

Wrap the native tokens and send the WAERGO to a destination address.

Call the wrap_to function, sending the aergo tokens that should be wrapped.

contract.call.value(amount)(waergo, "wrap_to", address)

If the destination is a contract, it must implement the tokensReceived() interface.

Unwrap

Call the unwrap function, informing the amount of tokens that should be unwrapped.

On a contract, you can inform the payable function that will receive the native tokens:

contract.call(waergo, "unwrap", amount, "receive_aergo")

If the contract has a default function marked as payable, then there is no need to inform the function name.

Unwrap To

Unwrap the WAERGO to native AERGO and send them to a destination account.

On a contract:

If the destination is a normal account:

contract.call(waergo, "unwrap_to", amount, to)

If the destination is a contract, we can inform the payable function that will receive the native tokens:

contract.call(waergo, "unwrap_to", amount, to, "receive_aergo")

If the destination contract has a default function marked as payable, then there is no need to inform the function name.

Transfer

As it follows the ARC1 standard, we can make transfers in the same way as for any ARC1 token.

Publishing the token contract

Run:

./build.sh

Then deploy the generated output.lua to the network.

wrapped-aergo's People

Contributors

kroggen avatar

Watchers

Hayarobi Park avatar  avatar ultrafellen avatar  avatar

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.