# Thoughts on the token standard

**URL:** <https://forum.dfinity.org/t/thoughts-on-the-token-standard/4694>\
**Category:** Developers\
**Created:** [June 3, 2021, 12:27am UTC](https://forum.dfinity.org/t/thoughts-on-the-token-standard/4694 "2021-06-03T00:27:42Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![senior.joinu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/senior.joinu/32/9240_2.png) [@senior.joinu](https://forum.dfinity.org/u/senior.joinu)\
**Post date:** [June 3, 2021, 12:29am UTC](https://forum.dfinity.org/t/thoughts-on-the-token-standard/4694/8 "2021-06-03T00:29:57Z")

</div>

_the next notation is given in rust_

```auto
trait IFungibleToken {
  
  // adds a caller's *callback* to the subscriber list, 
  // from now on each time there appears a transfer *from* -> *to*, 
  // the *callback* method will be called asynchronously,
  // without an awaiting
  // 
  //
  // *from* and *to* are filters applied by AND rule:
  //
  // subscribe(Some(Some("aaaa-a")), Some(Some("bbbb-b")), "cb")
  // creates a subscription that is triggered only when there is a transfer
  // from "aaaa-a" to "bbbb-b"
  //
  // subscribe(Some(Some("aaaa-a")), None), "cb")
  // creates a subscription that is triggered only when "aaaa-a" is a sender
  //
  // subscribe(None, Some(Some("bbbb-b")), "cb")
  // creates a subscription that is triggered only when "bbbb-b" is a recipient
  //
  // subscribe(None, None), "cb")
  // creates a subscription that is triggered on each transfer, no matter
  // who are the participants
  fn subscribe(
    from: Option<Option<Principal>>, 
    to: Option<Option<Principal>>,
    callback: String
  );

  // removes the caller's *callback* from the subscriber list
  fn unsubscribe(callback: String);

  // NOT A PART OF THE STANDARD - just for demo purposes
  // calls a subscriber's *callback* method with transfer details as a payload
  fn _publish(
    sub_canister_id: Principal,
    sub_method_name: String,
    from: Option<Principal>,
    to: Option<Principal>,
    qty: u64
  );

  // creates new tokens for *to*
  // calls every callback method subscribed 
  // to *from: Some(None)* or *to: Some(to)*
  fn mint(to: Principal, qty: u64);

  // sends token from caller to *to*
  // calls every callback method subscribed 
  // to *from: Some(caller)* or *to: Some(to)*
  fn send(to: Principal, qty: u64);

  // destroys tokens of the caller
  // calls every callback method subscribed 
  // to *from: Some(caller)* or *to: Some(None)*
  fn burn(qty: u64);

  // returns the balance of *token_holder*
  fn balance_of(token_holder: Principal) -> u64;

  // returns the total amount of tokens in circulation
  fn total_supply() -> u64;

}

```

---

_[View the full topic](https://forum.dfinity.org/t/thoughts-on-the-token-standard/4694)._
