No internet connection
  1. Home
  2. Smart Contracts

in CW20, can a contract send token to a person with transfer from?

By Orkun Külçe @orkunkl
    2020-07-27 10:36:44.933Z

    in CW20, can a contract send token to a person with transfer from?

    • 1 replies
    1. Orkun Külçe @orkunkl
        2020-07-27 10:37:19.730Z

        It is in env.contract.address in init, handle, and query. We create the address before calling init.
        If you want to convert between canonical form (raw bytes) and the human form (which is bech32 with proper prefix for sdk, could be different) then just call the functions on deps.api, you see them used all over the place in sample contracts
        A contract can send it's own tokens to any account (person or contract) with transfer.
        I don't see the need for transfer from when we have send, except for off chain clients wanting to share some tokens with another off chain account (contracts shouldn't need jt). It is defined in spec, but not yet implemented.