以太坊 Iban 地址

本文节选自电子书《Netkiller Blockchain 手札》

Netkiller Blockchain 手札

Mr. Neo Chan, 陈景峯(BG7NYT)

中国广东省深圳市龙华新区民治街道溪山美地 518131 +86 13113668890 <netkiller@msn.com>

文档始创于2018-02-10

版权 © 2018 Netkiller(Neo Chan). All rights reserved.

版权声明

转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。

内容摘要

这一部关于区块链开发及运维的电子书。

为什么会写区块链电子书?因为2018年是区块链年,区块链是一个风口,前几个风口我都错过了。例如web2.0, 云, 大数据等等,都从身旁擦肩而过。所以我要抓住这次。

这本电子书是否会出版(纸质图书)? 不会,因为互联网技术更迭太快,纸质书籍的内容无法实时更新,一本书动辄百元,很快就成为垃圾,你会发现目前市面的上区块链书籍至少是一年前写的,内容已经过时,很多例子无法正确运行。所以我不会出版,电子书的内容会追逐技术发展,及时跟进软件版本的升级,做到内容最新,至少是主流。

这本电子书与其他区块链书籍有什么不同?市面上大部分区块链书籍都是用2/3去讲区块链原理,只要不到 1/3 的干货,干货不够理论来凑,通篇将理论或是大谈特谈区块链行业,这些内容更多是头脑风暴,展望区块链,均无法落地实施。本书与那些书籍完全不同,不讲理论和原理,面向应用落地,注重例子,均是干货。

写作原则,无法落地的项目作者绝对不会写。凡是写入电子的内容均具备可操作,可落地。

电子书更新频率?每天都会有新内容加入,更新频率最迟不会超过一周,更新内容请关注 https://github.com/netkiller/netkiller.github.io/commits/master

本文采用碎片化写作,原文会不定期更新,请尽量阅读原文 http://www.netkiller.cn/blockchain/index.html

您的打赏是我的写作动力:http://www.netkiller.cn/blockchain/donations.html

接受 ETH 打赏:0x3e827461Cc53ed7c75A29187CfF39629FCAE3661


相关文章 https://github.com/ethereum/wiki/wiki/ICAP:-Inter-exchange-Client-Address-Protocol

Contents

Transferring funds between third-party accounts, especially those of exchanges, places considerable burden on the user and is error prone, due to the way in which deposits are identified to the client account. This problem was tackled by the existing banking industry through having a common code known as IBAN. This code amalgamated the institution and client account along with a error-detection mechanism practically eliminating trivial errors and providing considerable convenience for the user. Unfortunately, this is a heavily regulated and centralised service accessible only to large, well-established institutions. The present protocol, ICAP, may be viewed as a decentralised version of it suitable for any institutions containing funds on the Ethereum system.

IBAN

For a good overview of the IBAN system, please see Wikipedia's IBAN article. An IBAN code consists of up to 34 case insensitive alpha-numeric characters. It contains three pieces of information:

  • The country code; a top-level identifier for the context of the following (ISO 3166-1 alpha-2);
  • The error-detection code; uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003);
  • The basic bank account number (BBAN); an identifier of the institution, branch and client account, whose composition is dependent on the aforementioned country.

For the UK, the BBAN is composed of:

  • Institution identifier, 4-character alphabetical, e.g. MIDL (ironically) represents HSBC bank.
  • Sort-code (branch identifier within the institution), a 6-digit decimal number, e.g. 402702 would be the Lancaster branch of HSBC.
  • Account number (client identifier within the branch), an 8-digit decimal number.

Proposed Design

Introduce a new IBAN country code: XE, formulated as the Ethereum E prefixed with the "extended" X, as used in non-jurisdictional currencies (e.g. XRP, XCP).

There will be three BBAN possibilities for this code; direct, basic and indirect.

Direct

The BBAN for this code when direct will be 30 characters and will comprise one field:

  • Account identifier, 30 characters alphanumeric (< 155-bit). This will be interpreted as a big-endian encoded base-36 integer representing the least significant bits of a 160-bit Ethereum address. As such, these Ethereum addresses will generally begin with a zero byte.

e.g. XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS corresponds to the address 00c5496aee77c1ba1f0854206a26dda82a81d6d8.

Basic

The same as the direct encoding, except that the code is 31 characters (making it non-compliant for IBAN) and composes the same, single, field:

  • Account identifier, 31 characters alphanumeric (< 161-bit). This will be interpreted as a big-endian encoded base-36 integer representing a 160-bit Ethereum address.

Indirect

The BBAN for this code when indirect will be 16 characters and will comprise three fields:

  • Asset identifier, 3-character alphanumeric (< 16-bit);
  • Institution identifier, 4-character alphanumeric (< 21-bit);
  • Institution client identifier, 9-character alphanumeric (< 47-bit);

Including the four initial characters, this leads to a final client-account address length of 20 characters, of the form:

Split into:

  • XE The country code for Ethereum;
  • 81 The checksum;
  • ETH The asset identifier within the client account - in this case, "ETH" is the only valid asset identifier, since Ethereum's base registry contract supports only this asset;
  • XREG The institution code for the account - in this case, Ethereum's base registry contract;
  • GAVOFYORK The client identifier within the institution - in this case, a direct payment with no additional data to whatever primary address is associated with the name "GAVOFYORK" in Ethereum's base registry contract;

Notes

Institution codes beginning with X are reserved for system use.

Other forms

URI

General URIs can be formed though the URI scheme name iban, followed by the colon character :, followed by the 20-character alphanumeric identifier, thus for the example above, we would use:

QR Code

A QR code may be generated directly from the URI using standard QR encodings. For example, the example above iban:XE81ETHXREGGAVOFYORK would have the corresponding QR code:

Transaction Semantics

The mechanism for indirect asset transfer over three routing protocols are specified, all of which are specific to the Ethereum domain (country-code of XE). One is for currency transfers directly to an included address ("direct"), another is for clients with the system address found through a Registry-lookup system of the client-ID, denoted by asset class ETH, whereas the last is for transfers to an intermediary with associated data to specify client, denoted by asset class XET (the latter two are "indirect").

Direct

If the IBAN code is 34 characters, it is a direct address; a direct transfer is made to the address which, when base-36 encoded gives exactly the data segment (the last 30 characters) of the IBAN code.

Indirect ETH Asset: Simple transfers

Within the ETH asset code of Ethereum's country-code (XE), i.e. as long as the code begins with XE**ETH (where ** is the valid checksum), then we can define the required transaction to be the deposit address given by a call to the registry contract denoted by the institution code. For institutions not beginning with X, this corresponds to the primary address associated with the Ethereum standard name:

[institution code] / [client identifier]

The Ethereum standard name is simply the normal hierarchical lookup mechanism, as specified in the Ethereum standard interfaces document.

We define a registry contract as a contract fulfilling the Registry interface as specified in the Ethereum standard interfaces document.

TODO: JS code for specifying the transfer.

Indirect XET Asset: Institution transfers

For the XET asset code within the Ethereum country code (i.e. while the code begins XE**XET), then we can derive the transaction that must be made through a lookup to the Ethereum iban registry contract. For a given institution, this contract specifies two values: the deposit call signature hash and the institution's Ethereum address.

At present, only a single such deposit call is defined, which is:

whose signature hash is 0x13765838. The transaction to transfer the assets should be formed as an ether-laden call to the institution's Ethereum address using the deposit method as specified above, with the client account determined through the value of the big-endian, base-36 interpretation of the alpha-numeric Institution client identifier, literally using the value of the characters 0 to 9, then evaluating 'A' (or 'a') as 10, 'B' (or 'b') as 11 and so forth.

TODO: JS code for specifying the transfer.

IBAN 格式如下

iban:XE4214YF25M7C0Q6QFUF989GYBCR29987SX?amount=100&token=ETH

处理程序

	public static void main(String[] args) {
		IBAN iban = new IBAN();
		// TODO Auto-generated method stub
		String address = iban.toAddress("XE039RBH0XKV9FZMTH2701Q37FLX10NTWXU");
		System.out.println("IBAN to Address: " + address);

		String ibanAddress = iban.toIban("0x538b392D57d867A57eE8Eed05737cB08B4691302");
		System.out.println("Address to IBAN: " + ibanAddress);

		Iban ibanObj = iban.decode("iban:XE039RBH0XKV9FZMTH2701Q37FLX10NTWXU?token=ETH&amount=5");
		System.out.println("IBAN decode: " + ibanObj.toString());

		String ibanString = iban.encode("0x538b392D57d867A57eE8Eed05737cB08B4691302", "NBRC", "5");
		System.out.println("IBAN encode: " + ibanString);
	}

运行结果

IBAN to Address: 0x538b392d57d867a57ee8eed05737cb08b4691302
Address to IBAN: XE039RBH0XKV9FZMTH2701Q37FLX10NTWXU
IBAN decode: Iban [ibanAddress=0x538b392d57d867a57ee8eed05737cb08b4691302, token=ETH, amount=5]
IBAN encode: iban:XE039RBH0XKV9FZMTH2701Q37FLX10NTWXU?token=NBRC&amount=5

原创声明,本文系作者授权云+社区发表,未经许可,不得转载。

如有侵权,请联系 yunjia_community@tencent.com 删除。

编辑于

我来说两句

1 条评论
登录 后参与评论

相关文章

来自专栏一个会写诗的程序员的博客

《MongoDB极简教程》第一章 NoSQL简史 & MongoDB安装&环境配置NoSQLNoSQL 简史CAP定理(CAP theorem)BASEMongoDB 特性&优势文档参考安装&环境配置

MongoDB 是一款开源的文档数据库,并且是业内领先的 NoSQL 数据库,用 C++ 编写而成。

653
来自专栏landv

16位和32位的80X86汇编语言的区别

682
来自专栏杨建荣的学习笔记

今天处理的三个小问题——20160120(r7笔记第84天)

今天处理了几件事情,有几件还比较有意思,我拿出三件来说说。 首先是早上有一个同学打电话求助一个问题,给我的反馈是他们目前有一个表,数据量越来越大,目前数据插入变...

2724
来自专栏北京马哥教育

8分钟掌握Linux内核分析的核心科技

作者: OUYANG_LINUX007 来源: http://blog.csdn.net/ouyang_linux007/article/details/742...

3105
来自专栏友弟技术工作室

EOS.IO 技术白皮书背景区块链应用的要求共识算法 (DPOS)帐户应用程序的确定性并行执行Token 模型与资源使用治理脚本 & 虚拟机跨链通信总结

草案:2017 年 6 月 26 日 (@dayzh (https://steemit.com/@dayzh))

682
来自专栏Seebug漏洞平台

VxWorks Fuzzing 之道:VxWorks 工控实时操作系统漏洞挖掘调试与利用揭秘

来自404实验室安全研究团队的对于VxWorks 工控实时操作系统进行的 Fuzzing 与漏洞挖掘调试、利用的安全探究。 0x00 前言 关于VxWorks,...

3525
来自专栏乐享123

How to Sort a Very Very Very Big File

1295
来自专栏双十二技术哥

Android性能优化(九)之被忽视的电量

移动互联网的大潮到来之后,我们都变身好男人:“用智能手机的男人都是好男人,因为晚上必须回家充电。”一句笑言,但也可以看得出来目前使用智能设备电量方面的问题。

893
来自专栏吉浦迅科技

DAY73:阅读Programming Guidelines

我们正带领大家开始阅读英文的《CUDA C Programming Guide》,今天是第73天,我们正在讲解CUDA 动态并行,希望在接下来的27天里,您可以...

713
来自专栏腾讯Bugly的专栏

如何定位Obj-C野指针随机Crash(二):让非必现Crash变成必现

继上一篇如何定位Obj-C野指针随机Crash介绍了思路后,这次我们继续看,如何让非必现Crash变为必现。 ? 陈其锋,腾讯SNG即通产品部音视频技术中心软件...

3973

扫码关注云+社区