以太坊 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 删除。

编辑于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏Netkiller

EOS 智能合约中数据表的操作方法

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

2559
来自专栏区块链入门

【以太坊通证标准】ERC20系列,ERC721系列,ERC865

【本文目标】 通过本文学习,了解ERC定义及知名ERC协议标准,如ERC20以及ERC223、ERC621,ERC827协议,ERC721以及 ERC875,...

1192

NBitcoin:最完整的比特币港口(第1部分:加密)

Codeproject的研究员们,我很高兴发布系列的第一篇文章。[NEW:第2部分在这里 ]我最近从C++到C#移植了一部分很棒的比特币源代码。我导入了几乎所有...

1.2K14
来自专栏醒者呆

以太坊源码机制:挖矿

狗年吉祥,开工利是,我们继续研究以太坊源码。从本篇文章开始,我们会深入到以太坊核心源码中去,进而分析与研究以太坊的核心技术。 关键字:拜占庭,挖矿,矿工...

7007
来自专栏Golang语言社区

Oculus + Node.js + Three.js 打造VR世界

Oculus Rift 是一款为电子游戏设计的头戴式显示器。这是一款虚拟现实设备。这款设备很可能改变未来人们游戏的方式。 周五Hackday Showcase的...

4818
来自专栏生信技能树

GEO数据挖掘-第一期-胶质母细胞瘤(GBM)

lncRNAs PVT1 and HAR1A are prognosis biomarkers and indicate therapy outcome for...

2735
来自专栏程序员的酒和故事

跟Google学写代码--Chromium/base--cpu源码学习及应用

Chromium是一个伟大的、庞大的开源工程,很多值得我们学习的地方。 前面写道: 《跟Google学写代码–Chromium/base–stl_util源...

3627
来自专栏SeanCheney的专栏

链课堂01 | 解密超级账本-Fabric运行机制

2112
来自专栏区块链技术指北

Python 统计个人加密货币资产

这是「区块链技术指北」的第 7 篇文章。 如果对我感兴趣,想和我交流,我的微信号:Wentasy,加我时简单介绍下自己,并注明来自「区块链技术指北」。同时我会把...

3586
来自专栏工科狗和生物喵

C++初入门,写个弱智银行卡系统

写在前面: 自从课程设计之后,我们就开始了生产实习,我们老师找的是河南卫华集团的技术部实习,经过一阵子的不适应(比如说河南这边的基本没味道的伙食,我们现在两个人...

45811

扫码关注云+社区