Bitcoin Forum
May 02, 2024, 09:18:52 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Convert Ethereum ABI Address To String (Solidity)  (Read 106 times)
Kruddler (OP)
Jr. Member
*
Offline Offline

Activity: 51
Merit: 56


View Profile
December 28, 2017, 10: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);
}
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!