Vyper how to convert uint256 to String?

Viewed 964

I need to convert a uint256 to String in vyper, I notice that theres something similar on Solidity (Taken from OpenSea's docs):

/**
   * @dev Returns an URI for a given token ID
   */
  function tokenURI(uint256 _tokenId) public view returns (string) {
    return Strings.strConcat(
        baseTokenURI(),
        Strings.uint2str(_tokenId)
    );
  }

There's a method called "Strings.uint2str()", is there something equivalent in Vyper?

1 Answers

the vyper git repo has an examples folder, one of which is for tokens which contains and ERC-721 contract implementation in vyper

@view
@external
def tokenURI(tokenId: uint256) -> String[132]:
    return concat(self.baseURL, uint2str(tokenId))

in the vyper docs

uint2str(value: unsigned integer)→ String Returns an unsigned integer’s string representation.

value: Unsigned integer to convert.

Returns the string representation of value.

Related