#Convert bytes array to Address Account type

14 messages · Page 1 of 1 (latest)

granite mulch
#

I want to know how can i convert bytes array into Address Account type inside smart contract

chrome tendon
#

you can't. in the next release you'll be able to convert any valid G... or C... strkey to an address. does your use case require using bytes specifically? what are these bytes representing?

granite mulch
#

I have a message that contains both an amount and an address represented as bytes. I pass this entire message as bytes to my smart contract from the client side. Inside the smart contract, I need to convert the bytes representing the address into an Address account type. My goal is to mint some tokens to this address. How can I correctly convert these bytes into the Address account type within my smart contract and then proceed to mint tokens to this address?

chrome tendon
#

where this address comes from, i.e. who encoded it as bytes in the first place?

daring flicker
#

Another chain my guess

#

Or their agent that creates the message

chrome tendon
#

ok, but who encoded it for the other chain then?

#

like someone has to take the input address from the user (e.g. a strkey). why not just pass it around as strkey or (better) ScVal::Address? the latter can be just directly used as Address

daring flicker
#

Im just guessing 🙂 but i agree itd be better to just match our encoding types

chrome tendon
#

yeah, I mean that's a totally fair point/use case... but thinking about this more holistically, the endpoint would need to deal with Stellar entities and thus it seems like it should be at least theoretically possible to keep the Stellar entities encoded in Stellar-supported way...

daring flicker
#

It seems like the offchain agent could convert the data

#

If my guess of it being a cross chain messager is correct

chrome tendon
#

sure, it doesn't really matter which entity it is, what matters is that there needs to be some stellar-specific logic, so might as well benefit from using the structured data and not reinventing the wheel (serialization format)

daring flicker
#

Serialization inside the contracts are probably easier on evm since execution limits dont mean much there. My guess is this methodology is getting carried over from that world