Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARC-0200 draft #223

Merged
merged 38 commits into from
Sep 4, 2023
Merged
Changes from 17 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fae2f7a
ARC-0200 draft
temptemp3 Jul 4, 2023
57fd900
fix: Typo + add:discussion-to
SudoWeezy Jul 4, 2023
fafe2c2
add missing args to ABI methods, use UInt256
temptemp3 Jul 5, 2023
6846734
remove timestamp from event args
temptemp3 Jul 5, 2023
3a9e17b
fix method and event argument names
temptemp3 Jul 17, 2023
998989c
add arc200 prefix and core spec notes
temptemp3 Jul 17, 2023
3083fe5
revert arc200 prefix
temptemp3 Jul 17, 2023
bf3b753
revert from/to, fix typo
temptemp3 Jul 17, 2023
e4309b4
reward, fix argument names to be less common
temptemp3 Jul 21, 2023
715b226
Update ARCs/arc-0200.md
temptemp3 Jul 21, 2023
7f4c7cc
Update ARCs/arc-0200.md
temptemp3 Jul 21, 2023
b5c7eb1
Update ARCs/arc-0200.md
temptemp3 Jul 21, 2023
4209675
fix arg names
temptemp3 Jul 21, 2023
125f234
reword transferFrom approval
temptemp3 Jul 21, 2023
a9174bc
reword transferFrom spender error
temptemp3 Jul 21, 2023
9ec79b8
update arg names
temptemp3 Jul 25, 2023
286c37f
revert
temptemp3 Jul 25, 2023
d8d83ed
Update ARCs/arc-0200.md
temptemp3 Aug 5, 2023
a17600a
Update ARCs/arc-0200.md
temptemp3 Aug 5, 2023
0163779
Update ARCs/arc-0200.md
temptemp3 Aug 5, 2023
581c14a
Update ARCs/arc-0200.md
temptemp3 Aug 5, 2023
b958a5f
Update ARCs/arc-0200.md
temptemp3 Aug 5, 2023
70d8ae4
Update ARCs/arc-0200.md
temptemp3 Aug 5, 2023
27415c8
Update ARCs/arc-0200.md
temptemp3 Aug 5, 2023
50d39f6
Update ARCs/arc-0200.md
temptemp3 Aug 5, 2023
7427d29
Update ARCs/arc-0200.md
temptemp3 Aug 5, 2023
4e1209c
Update ARCs/arc-0200.md
temptemp3 Aug 5, 2023
b1e3a29
Update ARCs/arc-0200.md
temptemp3 Aug 7, 2023
4b69dbe
Update ARCs/arc-0200.md
temptemp3 Aug 7, 2023
38debe3
Update ARCs/arc-0200.md
temptemp3 Aug 7, 2023
07a68a4
Update ARCs/arc-0200.md
temptemp3 Aug 7, 2023
551c566
Update ARCs/arc-0200.md
temptemp3 Aug 7, 2023
b1bfde3
Update ARCs/arc-0200.md
temptemp3 Aug 7, 2023
90c9431
Update ARCs/arc-0200.md
temptemp3 Aug 7, 2023
eba7e87
Update ARCs/arc-0200.md
temptemp3 Aug 7, 2023
e8946e1
Update ARCs/arc-0200.md
temptemp3 Aug 7, 2023
8fecd91
Status to last Call
SudoWeezy Aug 8, 2023
f9dc882
Update arc-0200.md to living
SudoWeezy Sep 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 231 additions & 0 deletions ARCs/arc-0200.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
---
arc: 200
title: Algorand Smart Contract Token Specification
description: Base specification for tokens implemented as smart contracts
author: Nicholas Shellabarger (@temptemp3)
discussions-to: https://github.com/algorandfoundation/ARCs/issues/223
status: Draft
type: Standards Track
category: Interface
created: 2023-07-03
requires: 3, 4, 22, 28
---

# Algorand Smart Contract Token Specification

## Abstract

This ARC (Algorand Request for Comments) specifies an interface for tokens to be implemented on Algorand as smart contracts. The interface defines a minimal interface required for tokens to be held and transferred, with the potential for further augmentation through additional standard interfaces and custom methods.

## Motivation

Currently, most tokens in the Algorand ecosystem are represented by ASAs (Algorand Standard Assets). However, to provide rich extra functionality, it can be desirable to implement tokens as smart contracts instead. To foster an interoperable token ecosystem, it is necessary that the core interfaces for tokens be standardized.

## Specification

The key words "**MUST**", "**MUST NOT**", "**REQUIRED**", "**SHALL**", "**SHALL NOT**", "**SHOULD**", "**SHOULD NOT**", "**RECOMMENDED**", "**MAY**", and "**OPTIONAL**" in this document are to be interpreted as described in <a href="https://www.ietf.org/rfc/rfc2119.txt">RFC-2119</a>.

### Core Token specification

A smart contract token that is compliant with this standard MUST implement the following interface:

```json
{
"name": "ARC-200",
"desc": "Smart Contract Token Base Interface",
"methods": [
{
"name": "name",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Returns the name of the token",
"readonly": true,
"args": [],
"returns": { "type": "bytes[32]", "desc": "The name of the token" }
},
{
"name": "symbol",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Returns the symbol of the token",
"readonly": true,
"args": [],
"returns": { "type": "bytes[8]", "desc": "The symbol of the token" }
},
{
"name": "decimals",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Returns the decimals of the token",
"readonly": true,
"args": [],
"returns": { "type": "uint8", "desc": "The decimals of the token" }
},
{
"name": "totalSupply",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Returns the total supply of the token",
"readonly": true,
"args": [],
"returns": { "type": "uint256", "desc": "The total supply of the token" }
},
{
"name": "balanceOf",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Returns the current balance of the owner of the token",
"readonly": true,
"args": [
{
"type": "address",
"name": "owner",
"desc": "The address of the owner of the token"
}
],
"returns": {
"type": "uint256",
"desc": "The current balance of the holder of the token"
}
},
{
"name": "transfer",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Transfers tokens",
"readonly": false,
"args": [
{
"type": "address",
"name": "to",
"desc": "The destination of the transfer"
},
{
"type": "uint256",
"name": "value",
"desc": "Amount of tokens to transfer"
}
],
"returns": { "type": "bool", "desc": "Success" }
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
},
{
"name": "transferFrom",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Transfers tokens from source to destination as approved spender",
"readonly": false,
"args": [
{
"type": "address",
"name": "from",
"desc": "The source of the transfer"
},
{
"type": "address",
"name": "to",
"desc": "The destination of the transfer"
},
{
"type": "uint256",
"name": "value",
"desc": "Amount of tokens to transfer"
}
],
"returns": { "type": "bool", "desc": "Success" }
},
{
"name": "approve",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Approve spender for a token",
"readonly": false,
"args": [
{ "type": "address", "name": "spender" },
{ "type": "uint256", "name": "value" }
],
"returns": { "type": "bool", "desc": "Success" }
},
{
"name": "allowance",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Returns the current allowance of the spender of the tokens of the owner",
"readonly": true,
"args": [
{ "type": "address", "name": "owner" },
{ "type": "address", "name": "spender" }
],
"returns": { "type": "uint256", "desc": "The remaining allowance" }
}
],
"events": [
{
"name": "Transfer",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Transfer of tokens",
"args": [
{
"type": "address",
"name": "from",
"desc": "The source of transfer of tokens"
},
{
"type": "address",
"name": "to",
"desc": "The destination of transfer of tokens"
},
{
"type": "uint256",
"name": "value",
"desc": "The amount of tokens transferred"
}
]
},
{
"name": "Approval",
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
"desc": "Approval of tokens",
"args": [
{
"type": "address",
"name": "owner",
"desc": "The owner of the tokens"
},
{
"type": "address",
"name": "spender",
"desc": "The approved spender of tokens"
},
{
"type": "uint256",
"name": "value",
"desc": "The amount of tokens approve"
}
]
}
]
}
```

Ownership of a token by a zero address indicates that a token is out of circulation indefinitely, or otherwise burned or destroyed.
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved

The methods `transfer` and `transferFrom` method MUST error when the balance of `from` is insufficient. In the case of the `transfer` method, from is implied as the `owner` of the token.
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
The `transferFrom` method MUST error unless called by an `spender` approved by an `owner`.
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
The methods `transfer` and `transferFrom` MUST emit a `Transfer` event.
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
A `Transfer` event SHOULD be emitted, with `from` being the zero address, when a token is minted.
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
A `Transfer` event SHOULD be emitted, with `to` being the zero address, when a token is destroyed.
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved

The `Approval` event MUST be emitted when an `approve` or `transferFrom` method is called successfully.
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved

A value of zero for the `approve` method and the `Approval` event indicates no approval.
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved
The `transferFrom` method and the `Approval` event indicates the approval value after it is decremented.
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved

The contract MUST allow multiple operators per owner.
temptemp3 marked this conversation as resolved.
Show resolved Hide resolved

All methods in this standard that are marked as `readonly` MUST be read-only as defined by [ARC-22](./arc-0022.md).

## Rationale

This specification is based on <a href="https://eips.ethereum.org/EIPS/eip-20">ERC-20</a>.

### Core Specification

The core specification identical to ERC-20.

## Backwards Compatibility

This standard introduces a new kind of token that is incompatible with tokens defined as ASAs.
Applications that want to index, manage, or view tokens on Algorand will need to handle these new smart tokens as well as the already popular ASA implementation of tokens will need to add code to handle both, and existing smart contracts that handle ASA-based tokens will not work with these new smart contract tokens.

While this is a severe backward incompatibility, smart contract tokens are necessary to provide richer and more diverse functionality for tokens.

## Security Considerations

The fact that anybody can create a new implementation of a smart contract tokens standard opens the door for many of those implementations to contain security bugs.
Additionally, malicious token implementations could contain hidden anti-features unexpected by users.
As with other smart contract domains, it is difficult for users to verify or understand the security properties of smart contract tokens.
This is a tradeoff compared with ASA tokens, which share a smaller set of security properties that are easier to validate to gain the possibility of adding novel features.

## Copyright

Copyright and related rights waived via <a href="https://creativecommons.org/publicdomain/zero/1.0/">CCO</a>.