Author

Topic: Convert Ethereum ABI Address To String (Solidity) (Read 127 times)

jr. member
Activity: 51
Merit: 56
December 28, 2017, 05:44:21 PM
#1
I'm new to Ethereum so please excuse my ignorance. Ethereum seems to have an ABI serialization protocol called Solidity. The spec is here: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI

I'm looking for a way to encode and decode contracts in C#. Specifically, I want to take an array of bytes (byte[]) and convert it in to a human readable Ethereum address as a starting point.

Here are a couple of libraries that I've cloned, but after sifting through the code, it's not immediately apparent how to achieve what I am trying to do:

https://github.com/Nethereum/Nethereum

https://github.com/sense2k/Ethereum.NET

Can someone point me to an example of how to convert a byte array to a human readable Ethereum string address?

This is an example in what appears to be Go, but I can't quite follow how it works.

https://ethereum.stackexchange.com/questions/8346/convert-address-to-string

function toString(address x) returns (string) {
    bytes memory b = new bytes(20);
    for (uint i = 0; i < 20; i++)
        b = byte(uint8(uint(x) / (2**(8*(19 - i)))));
    return string(b);
}
Jump to: