0

I was reading the 04.token-contract(https://github.com/near-examples/workshop--exploring-assemblyscript-contracts/blob/master/assembly/A.sample-projects/04.token-contract/assembly/index.ts).

What's the concept difference between the exported functions:

export function transfer(to: string, tokens: u64): boolean

and

export function transferFrom(from: string, to: string, tokens: u64): boolean ?

And please, would it be okay to include a little documentation for this smart contract?

Thank you!

1 Answers1

0

Both functions are implementing the interface defined in the ERC-20 token standard.

transfer() is used for spending your own tokens.

If someone else has approved you (by executing the approve() function) to spend some of their tokens, you can use the transferFrom() function, pass their address as the from param, and spend tokens from their address (up to the approved amount).

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100