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
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
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.
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 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.
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 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.
As it follows the ARC1 standard, we can make transfers in the same way as for any ARC1 token.
Run:
./build.sh
Then deploy the generated output.lua
to the network.