Make Your Own Ergo Wallet: Managing Ergo Coins with ErgoTool

Translation temporarily unavailable. Showing original English.
Alexander Slesarenko

2019年12月31日

Introduction

ErgoTool is a command line interface (CLI) for
Ergo blockchain. You can use ErgoTool without running your
own Ergo node. Even though running a node is the most secure way to communicate with the
Ergo blockchain network, ErgoTool however, aims to provide more foundational tools at
your disposal. Surely, you still can use it with your own running node.

In this post we will walk through simple steps to generate a mnemonic phrase, create a
local secret storage and use it to send ERGs between addresses, all with the help of
ErgoTool commands.

Getting Started

First of all we need to install ErgoTool on our system from sources by following the
installation instructions. In the
directory where we cloned ErgoTool there is ergo-tool.sh script which we are going to
use to run commands. Run the following command to check ErgoTool is installed correctly.

$ ./ergo-tool.sh help     
command name is not specified (run ergo-tool without arguments to list commands)

Command Name:	help
Usage Syntax:	ergo-tool help <commandName>
Description:	prints usage help for a command
Doc page:	https://aslesarenko.github.io/ergo-tool/api/org/ergoplatform/appkit/ergotool/HelpCmd.html

Let's see what we get here. ErgoTool outputs the error message with the information about
help command. This is a typical output of ErgoTool when one of the known commands is
specified, but it is used incorrectly. As we can learn from the message, the help
command requires us to specify additional <commandName> argument. Also, each command has
an API doc page with all the details about command execution, so its url is shown here.

Create a New Mnemonic Phrase

Mnemonic is a random sequence of characters which is used to generate a master key
according to Hierarchical Deterministic
Wallets
specification.
For convenience random sequence of english words is used, but this is not required.
Run the following command to generate a new mnemonic phrase:

$ ./ergo-tool.sh mnemonic          
bird harbor wheat innocent business disease busy quick yellow trust time oil enter situate moon

Write it down on a paper and keep in a safe and secret place.
As an additional security measure you can create an arbitrary mnemonic password.
In some sense it can serve like an additional non-vocabulary word in the mnemonic.
Mnemonic password is optional and is used for additional security.
If you decide to use mnemonic password you should also write it down and keep in a secret and
probably different from mnemonic place.

Important, both mnemonic phrase and mnemonic password are required to restore secret keys,
if you lose any of them then you will not be able to regenerate you master key again.

Next let's use the generated mnemonic to create a storage with a master secret key.

Create a New Encrypted Storage

For better security neither mnemonic phrase nor password is required by ErgoTool to
perform the transaction signing. Instead, the secret key from the encrypted storage is
required to sign spending transaction. We can generate a secret key and store it in an
encrypted storage using createStorage command.

$ ./ergo-tool.sh help createStorage

Command Name:	createStorage
Usage Syntax:	ergo-tool createStorage [<storageDir>="storage"] [<storageFileName>="secret.json"]
Description:	Creates an encrypted storage file for the mnemonic entered by the user
Doc page:       https://aslesarenko.github.io/ergo-tool/api/org/ergoplatform/appkit/ergotool/CreateStorageCmd.html

$ ./ergo-tool.sh createStorage 
Enter mnemonic phrase> bird harbor wheat innocent business disease busy quick yellow trust time oil enter situate moon
Mnemonic password> 
Repeat mnemonic password> 
Storage password> 
Repeat storage password> 
Storage File: storage/secret.json

A master secret key is generated from the (mnemonic phrase, mnemonic password) pair and
saved encrypted in the storage/secret.json file. Mnemonic itself is not stored in the
file and there is no way to restore it from the file, even if you know the passwords.

Please take care to enter correct mnemonic password, the one you chose and saved before.
Since a mnemonic password is optional you can leave it empty by pressing enter.

If you forget the storage password (aka encryption password), you will not be able to use
that storage file anymore, however, you can always restore your secret keys from (mnemonic
phrase, mnemonic password) pair and thus create a new storage file with a new password.

Keep your storage file and storage password in secret, anyone who obtain both your storage
file and storage password will be able to decipher it and access secret keys.

Extracting Data From Storage

Secret storage contains master secret key and as a result can be used to compute both the
public key and the pay-to-public-key address which correspond to that secret key. The
extractStorage command is doing just that.

$ ./ergo-tool.sh help extractStorage

Command Name:	extractStorage
Usage Syntax:	ergo-tool extractStorage <storage file> address|masterKey|publicKey|secretKey mainnet|testnet
Description:	Reads the file, unlocks it using password and extract the requested property from the given storage file.
Doc page:	https://aslesarenko.github.io/ergo-tool/api/org/ergoplatform/appkit/ergotool/ExtractStorageCmd.html 

$ ./ergo-tool.sh extractStorage storage/secret.json address mainnet     
Storage password> 
9iHiSAg3ko2ZGxR2vhc1Aem3tShqfzEPDAF7XK5cdtbZ3Ut2CCf

Here the command transforms the secret key to the corresponding public key and then creates
the pay-to-public-key address on the mainnet.

The same way we can obtain public key, private key and other data from the storage.

$ ./ergo-tool.sh extractStorage storage/secret.json secretKey mainnet
Storage password> 
55dfde63c9b6b4f47683592e85ee997ba2e93507f38ba3f9c82933bcfbc677ca

$ ./ergo-tool.sh extractStorage storage/secret.json publicKey mainnet
Storage password> 
03f07aecb145a85920bf6e9be80efe5f1cd1a165b45ad3aa8e5c4ca3ba50856bb8

Listing Unspent Boxes

ErgoTool has the special command to list all available (aka unspent) boxes for a given address.

$ ./ergo-tool.sh listAddressBoxes 9f4QF8AD1nQ3nJahQVkMj8hFSVVzVom77b52JU7EW71Zexg6N8v                                                                
BoxId                                                             NanoERGs          
4840cb6facc20b765085db0ad24768ed0c5e7afd413e8e58e597c33a993f8119  4987000000

if we specify --print-json option, then ErgoTool will output all the boxes in json format

$ ./ergo-tool.sh listAddressBoxes --print-json 9f4QF8AD1nQ3nJahQVkMj8hFSVVzVom77b52JU7EW71Zexg6N8v
[{"boxId":"4840cb6facc20b765085db0ad24768ed0c5e7afd413e8e58e597c33a993f8119","value":4987000000,"ergoTree":"0008cd02472963123ce32c057907c7a7268bc09f45d9ca57819d3327b9e7497d7b1cc347","creationHeight":125646,"assets":[],"additionalRegisters":{},"transactionId":"820c688f4b9d709924ba0186ee930a7df374d8852920bc769fc1f1d0b313e5ab","index":2}]

Transfer Coins

Now, with secret key stored securely in the encrypted storage file, we can use ErgoTool to
transfer coins from our address to some other recipient address. The command to do that is
send.

./ergo-tool.sh help send                                     

Command Name:	send
Usage Syntax:	ergo-tool send <storageFile> <recipientAddr> <amountToSend>
Description:	send the given <amountToSend> to the given <recipientAddr> using 
 the given <storageFile> to sign transaction (requests storage password)
Doc page:	https://aslesarenko.github.io/ergo-tool/api/org/ergoplatform/appkit/ergotool/SendCmd.html

The storage file is necessary in order to access secret key and generate a signature. The
storage password will be requested by ErgoTool to unlock and decipher the file content.
The command send supports the --dry-run option which forces ErgoTool to create the
signed transaction, but instead of sending it to the blockchain, ErgoTool prints the
transaction on the console.

$ ./ergo-tool.sh send --dry-run storage/E1.json 9hHDQb26AjnJUXxcqriqY1mnhpLuUeC81C4pggtK7tupr92Ea1K 5000000
Storage password>
Creating prover... Ok
Loading unspent boxes from at address 9f4QF8AD1nQ3nJahQVkMj8hFSVVzVom77b52JU7EW71Zexg6N8v... Ok
Signing the transaction... Ok
Tx: {
  "id": "2633733a1d81b8fc747d984bdc36fac42cb52118b5057375b081b4c543c62b0e",
  "inputs": [
    {
      "boxId": "4840cb6facc20b765085db0ad24768ed0c5e7afd413e8e58e597c33a993f8119",
      "spendingProof": {
        "proofBytes": "060e7c99c9c9cecf89ec5c3e7b692075e0b3415318f8064c64f7f01401ac29c6637b44535151e51d43d4cd25e05ad459dbe33718a99a22dd",
        "extension": {}
      }
    }
  ],
  "dataInputs": [],
  "outputs": [
    {
      "boxId": "4eaed414ae763158126859bbf912fa9ffb9ea67ac13d81d473b1c81ec65b06fd",
      "value": 5000000,
      "ergoTree": "ErgoTree(0,WrappedArray(),Right(ConstantNode(SigmaProp(ProveDlog(ECPoint(6ba5cf,8ae5ac,...))),SSigmaProp)),80,[B@1117fff48)",
      "creationHeight": 130508,
      "assets": [],
      "additionalRegisters": {},
      "transactionId": "2633733a1d81b8fc747d984bdc36fac42cb52118b5057375b081b4c543c62b0e",
      "index": 0
    },
    {
      "boxId": "059b426fe2aaef10b6a9a618f0c5b4e97d4dd9931328bf4f52bcf92b0943a42c",
      "value": 1000000,
      "ergoTree": "ErgoTree(16,WrappedArray(IntConstant(0), IntConstant(0), ConstantNode(Coll(16,2,4,-96,11,8,-51,2,121,-66,102,126,-7,-36,-69,-84,85,-96,98,-107,-50,-121,11,7,2,-101,-4,-37,45,-50,40,-39,89,-14,-127,91,22,-8,23,-104,-22,2,-47,-110,-93,-102,-116,-57,-89,1,115,0,115,1),Coll[SByte$]), ConstantNode(Coll(1),Coll[SInt$]), IntConstant(1)),Right(BoolToSigmaProp(AND(ConcreteCollection(WrappedArray(EQ(Height$(163),SelectField(ExtractCreationInfo(ByIndex(Outputs$(165),ConstantPlaceholder(0,SInt$),None)),1)), EQ(ExtractScriptBytes(ByIndex(Outputs$(165),ConstantPlaceholder(1,SInt$),None)),SubstConstants(ConstantPlaceholder(2,Coll[SByte$]),ConstantPlaceholder(3,Coll[SInt$]),ConcreteCollection(WrappedArray(CreateProveDlog(DecodePoint(MinerPubkey$(172)))),SSigmaProp))), EQ(SizeOf(Outputs$(165)),ConstantPlaceholder(4,SInt$))),SBoolean)))),4836,[B@111805c40)",
      "creationHeight": 130508,
      "assets": [],
      "additionalRegisters": {},
      "transactionId": "2633733a1d81b8fc747d984bdc36fac42cb52118b5057375b081b4c543c62b0e",
      "index": 1
    },
    {
      "boxId": "0638ddb0fe6a8cc6ca4f981f71777f4a6e8aad72d57fdf945b24e0ef4ca714e1",
      "value": 4981000000,
      "ergoTree": "ErgoTree(0,WrappedArray(),Right(ConstantNode(SigmaProp(ProveDlog(ECPoint(472963,7c85fd,...))),SSigmaProp)),80,[B@111816258)",
      "creationHeight": 130508,
      "assets": [],
      "additionalRegisters": {},
      "transactionId": "2633733a1d81b8fc747d984bdc36fac42cb52118b5057375b081b4c543c62b0e",
      "index": 2
    }
  ]
}

Note the "ergoTree" scripts are deserialized and printed as abstract syntax trees. This
printing format can be regulated by additional options so that the scripts can be printed as
human readable ErgoScript. (Not yet implemented, but somewhere on the roadmap.)

If we exclude --dry-run option, the transaction will be sent and included in the
blockchain.

$ ./ergo-tool.sh send storage/E1.json 9hHDQb26AjnJUXxcqriqY1mnhpLuUeC81C4pggtK7tupr92Ea1K 5000000          
Storage password>
Creating prover... Ok
Loading unspent boxes from at address 9f4QF8AD1nQ3nJahQVkMj8hFSVVzVom77b52JU7EW71Zexg6N8v... Ok
Signing the transaction... Ok
Sendng the transaction... Ok
Server returned tx id: "c5710af17f5124a232a5ef731fdf94a493025334c2a7d5a79e9923210972b962"

The newly created transaction will be broadcast all over the blockchain and miners start
to include it in a new block. Once the new block with our transaction is mined and
accepted by the network our transfer is confirmed and we can see it in Explorer.

We can also list boxes of the recipient address and see the coin we created among others
(until it is spent by the recipient)

$ ./ergo-tool.sh listAddressBoxes 9hHDQb26AjnJUXxcqriqY1mnhpLuUeC81C4pggtK7tupr92Ea1K                      
BoxId                                                             NanoERGs          
252c5ce38fc367001ea48fa6813e6252ebc169288d9b5392c572edb55380b3cd  5000000
6df9dbf08b4859b7e280afbd0822dcf20dba5bf8e3e33b78fe278df6597276f1  2000000
d47f958b201dc7162f641f7eb055e9fa7a9cb65cc24d4447a10f86675fc58328  1000000
e050a3af38241ce444c34eb25c0ab880674fc23a0e63632633ae14f547141c37  1000000
b50ed8c2953fd33b52af816c4caa63ec5b6d236a262a5a192534695c3478da78  1000000
26d6e08027e005270b38e5c5f4a73ffdb6d65a3289efb51ac37f98ad395d887c  10000000000

Security Notes

ErgoTool is created with security in mind and tries its best to safeguard the usage of
sensitive information like mnemonic phrases (which are never stored persistently),
passwords (which are never shown on the screen) etc. In addition, secret keys are never
stored on local disk unencrypted and surely never sent anywhere.

Conclusion

ErgoTool is designed to look and feel like a typical CLI utility:

  • which is easy to use and fast to run from command line
  • can be scriptable via shell scripts
  • has built-in usage help

At the same time ErgoTool is designed to be easily extensible:

  • implemented in high-level language Scala
  • reuses the core libraries which are used in Ergo network client
  • open-sourced and fully documented

This last point is especially important as many new commands can be easily added to
ErgoTool, thanks to its architecture. If you need a specific feature or a command
please file an issue or maybe even a PR.

The extensibility of ErgoTool is a subject of the next planned blog post, stay tuned!

References

  1. Ergo Site
  2. Ergo Sources
  3. Ergo Appkit
  4. Ergo Tool

Share post

Ergo基础设施DAO:去中心化Ergo生态系统的支柱

Ergo基础设施DAO:去中心化Ergo生态系统的支柱

Ergo的使命一直根植于去中心化,不仅在共识层面,而是在整个技术栈中。随着Ergo基础设施DAO (InfraDAO)的推出,这一愿景正在扩展到每天为生态系统提供动力的服务和基础设施。 InfraDAO现在在Paideia上正式上线,经过成功的治理投票。最初.

Ergo Platform

2025年8月13日

Mew Finance:一个为Ergo生态系统提供的有趣DeFi工具包

Mew Finance:一个为Ergo生态系统提供的有趣DeFi工具包

Mew Finance是一个基于Ergo区块链的去中心化应用套件。该项目于2024年10月启动,将DeFi、数字资产和跨链功能整合到一个统一的平台中。长期社区开发者HQΣr和Aco Šmrkas领导该项目。设计上偏向模块化、易用性和深度生态系统集成。 本文是.

Ergo Platform

2025年8月12日

Lithos:通过链上矿池实现去中心化挖矿

Lithos:通过链上矿池实现去中心化挖矿

Lithos是一个新协议,旨在通过将矿池转移到链上来彻底改革矿池的运作方式,使矿工完全控制,并消除对中心化矿池运营商的需求。与之前大多数去中心化挖矿的尝试不同,Lithos旨在高效、可扩展和安全。 什么是Lithos? Lithos是一个去中心化的矿池协议.

Ergo Platform

2025年7月24日

Sigma 6.0:更智能、更灵活的Ergo

Sigma 6.0:更智能、更灵活的Ergo

Sigma 6.

Ergo Platform

2025年7月23日

塑造Rosen的未来:关于五项关键财政提案的社区呼吁

塑造Rosen的未来:关于五项关键财政提案的社区呼吁

Rosen的联合创始人Armeanio已向Rosen财政提交了五项新提案。这些提案概述了Rosen Bridge的增长、实用性和可扩展性的战略愿景,这是Ergo互操作性基础设施的核心组成部分。 这是Ergo社区审查和讨论这一重要跨链服务未来方向的关键时刻。以.

Ergo Platform

2025年7月9日

Ergo的扩展UTXO与人工经济智能的崛起

Ergo的扩展UTXO与人工经济智能的崛起

自主经济代理的实用愿景 Ergo区块链上的自主经济代理在真实的数字经济中执行有用的工作。它们通过创建内容和提供数据分析、模式识别等服务来产生收入。它们利用收入支付运营费用,如托管费和服务器成本,并使用现代工具,如SSH和加密友好的托管服务提供商。当有额外资金.

Ergo Platform

2025年5月12日

ErgoHACK X:在Ergo区块链上的人工智能

ErgoHACK X:在Ergo区块链上的人工智能

庆祝去中心化创新的十年 加入第十届ErgoHACK,站在Ergo区块链AI革命的最前沿!释放你的创造力,与其他创新者合作,共同构建去中心化AI的未来。 关于ErgoHack ErgoHACK,旗舰社区黑客马拉松,庆祝其十周年!这一里程碑事件是Ergo生态系统.

Ergo Platform

2025年4月10日

ERG正式上线Kucoin(库币)交易所

ERG正式上线Kucoin(库币)交易所

据Kucoin官方通告,Ergo平台原生代币ERG于8月3日正式上线Kucoin(库币)交易所。目前支持的交易对是ERG/USDT。现已开放充值;2021年8月5日UTC时间上午10:00开放交易;2021年8月6日UTC时间上午10:00开放提币。 .

Ergo Foundation

2021年8月3日

Ergo两周年纪念——早期采用者应了解的核心知识

Ergo两周年纪念——早期采用者应了解的核心知识

Normal 0 false false false EN-US ZH-CN X-NONE /* Style Definitions */ table.

root7Z

2021年7月5日

关于Ergo启用官方QQ频道的公告

关于Ergo启用官方QQ频道的公告

由于Ergo官方微信号暂无法使用,Ergo官方现新增Ergo官方QQ频道:796039547。全球中文用户可通过扫描下面的二维码加入Ergo中文社区,及时了解Ergo最新官方动态. .

Eva Qing

2021年6月30日

Ergo首届黑客松大赛ERGOHACK圆满结束

Ergo首届黑客松大赛ERGOHACK圆满结束

Ergo首届黑客松大赛已经圆满结束,它正如计划那样:规模小而富有实验性,但依然收到了一些很棒的作品提交。Kushti以他的开场视频拉开了活动的序幕,然后我们总共有六个团队,其中来自anon_real(AuctionHouse、SigmaUSD UI等项目的创建.

Curia Regis Crypto

2021年6月29日

关于举办首届Ergo中国社区驱动践行活动的公告

关于举办首届Ergo中国社区驱动践行活动的公告

为了进一步提高Ergo公链平台在中国的知名度,让更多用户深入了解Ergo,同时为了践行Ergo社区驱动的理念,Ergo中国社区现特别举办“首届Ergo中国社区驱动践行活动”。活动参与者积极向新用户布道Ergo并将其引至Ergo官方指定社群,将有机会赢取ERG奖.

Eva Qing

2021年6月4日

比特币的前进之路是努力追赶Ergo ——Ergo率先实现扩展UTXO智能合约

比特币的前进之路是努力追赶Ergo ——Ergo率先实现扩展UTXO智能合约

比特币 比特币是一头野兽。是的,其底层软件需要认真升级。它真的太慢了。但是,您也必须承认它的优势,网络效应是非常强大的------比特币是加密货币之王。在全球范围内,比特币正成为一个常见、被理解和被采用的术语。大型信托、投资巨头和对冲基金经理,都被比特币的主.

Curia Regis Crypto

2021年5月23日

关于Ergo基金会任命谭声情先生担任中国区大使的公告

关于Ergo基金会任命谭声情先生担任中国区大使的公告

经Ergo基金会批准,现任命谭声情先生(英文名:Tango)担任Ergo中国区大使。 为了提升Ergo在中国的知名度与影响力,Ergo基金会现授权谭声情先生以Ergo中国区大使身份进行Ergo在中国的品牌宣传、商务洽谈、社区活动、主题推广等事宜。 此任命自.

Ergo Team

2021年5月16日

硬分叉事后说明

硬分叉事后说明

英文链接: 应@kushti的请求,我现在给大家说明一下今天在硬分叉升级期间发生的事情。有一些BUG导致矿工无法出块,现已修补好这些BUG,矿工可以出块。 version2ActivationDifficultyHex中出现往返编码失败(Round-T.

Eva Qing

2021年2月3日

硬分叉升级后Ergo挖矿须知

硬分叉升级后Ergo挖矿须知

Ergo将在区块#417,792上进行硬分叉协议升级。此次升级会引入重大更改,包括将关闭不可外包功能(Non-Outsourceability)。经过此次硬分叉之后,新的PoW(被称为Autolykos v2.

Eva Qing

2021年2月1日

如何设置和配置Ergo全节点

如何设置和配置Ergo全节点

如何设置和配置Ergo全节点 本教程说明了如何安装和运行Ergo全节点,不涵盖挖矿。  Windows用户还可以观看视频教程。 如何在Windows上设置和配置Ergo全节点 视频链接: 节点安全 这里是节点使用的一些重要方面,您的钱包及代币是否安全.

Eva Qing

2021年1月21日

既想享受乐趣,又想赚取利润? ——那就赶紧来挖ERG

既想享受乐趣,又想赚取利润? ——那就赶紧来挖ERG

Ergo GPU挖矿 本文将帮助您开始使用GPU挖矿Ergo原生代币ERG。 Ergo挖矿基于Autolykos,即一种工作量证明(PoW)算法,被设计为阻碍ASIC矿机和矿池。矿工须执行存储困难的计算(需要至少4 GB的内存,但是当前最有效的实现使用的是.

Eva Qing

2021年1月21日

适用于AMD GPU的Autolykos v2(Ergo)的OpenCL挖矿软件

适用于AMD GPU的Autolykos v2(Ergo)的OpenCL挖矿软件

适用于ergoplatform.

Eva Qing

2021年1月19日

适用于Nvidia GPU的Autolykos v2(Ergo)用Cuda挖矿软件

适用于Nvidia GPU的Autolykos v2(Ergo)用Cuda挖矿软件

用于ergoplatform.

Eva Qing

2021年1月19日

尔格基金会为主要去中心化应用(dApp)基础设施提供资助

尔格基金会为主要去中心化应用(dApp)基础设施提供资助

尔格基金会将考虑支持重大生态系统开发项目提供资助的建议。 尔格是一个面向社区的项目,该生态系统的方方面面都有许多贡献者。尔格基金会会拿出一部分资金资助此项工作,这对于构建用户所需的日常产品与服务以及更多样化的金融去中心化应用至关重要。该基金会正在积极寻求.

Guy Brandon

2020年11月17日