0

Is there way to construct an Address from a byte array of UInt8 in Cadence?

Docs have this example:

let someAddress: Address = 0x436164656E636521
someAddress.toBytes()

What I've tried:

let hexStr = String.encodeHex([0,0,0,0,0,0,0,1])
let addrStr = "0x".concat(hexStr) // gives a string in format '0x0000000000000001' but how cast to Address type?

Possible to do UInt8 byte array to Address?

The use case is to build an Address in a tx from an RLP-encoded data function argument.

Gurra
  • 5
  • 2

1 Answers1

0

This contract has some utilities for working with Addresses and parsing them from other types. Sending in a string here works for instance.

https://github.com/green-goo-dao/flow-utils/blob/main/cadence/contracts/AddressUtils.cdc

bjartek
  • 929
  • 1
  • 5
  • 11