Skip to content

"str" type cannot be derived from Account or Address type #345

@atsoc1993

Description

@atsoc1993

Problem

Was trying to mint an ARC69 via smart contract, and include a property for "Owner", but could not represent the Address as a string, see "Owner" field in asset creation transaction below.

Attempted to pass in the account as a String type, but Account only excepts str or Bytes type, Address only supports str, Bytes, or Account type.

 

pokemon_creation_tx = itxn.AssetConfig(
            total=1,
            manager=Global.current_application_address,
            asset_name=available_pokemon_info.pokemon_name.native,
            unit_name='PK#' + unit_name_int_as_string,
            decimals=0,
            url= 'https://gateway.pinata.cloud/ipfs/' + available_pokemon_info.pokemon_ipfs_hash.native,
            note = (
                '{"standard": "arc69", "mime_type": "image/png", "properties": {'
                '"Type": "' + available_pokemon_info.pokemon_type.native + '", '
                '"Description": "' + available_pokemon_info.pokemon_description.native + '", '
                '"Level": "1", '
                '"Experience": "0", '
                '"Pokemon Number": "' + unit_name_int_as_string + '", '
                '"Owner": "' + ******* + '", '
                '"UID": "' + uid_as_string + '" }}' 
            ),
            fee=Global.min_txn_fee
        ).submit()

Solution

Allow decoding methods to str types, perhaps as Account.str attribute, or String.str attribute for string literals

While on the topic it is important to note there is no itoa support (Integer to Ascii), and currently we have to manually input this function into our programs to convert integers into strings:

    @subroutine
    def itoa(self, i: UInt64) -> Bytes:
        digits = Bytes(b"0123456789")
        radix = digits.length
        if i < radix:
            return digits[i]
        return self.itoa(i // radix) + digits[i % radix]
      

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions