Skip to content

Latest commit

 

History

History
122 lines (81 loc) · 4.63 KB

nep-6.mediawiki

File metadata and controls

122 lines (81 loc) · 4.63 KB

  NEP: 6
  Title: Wallet Standard
  Author: Erik Zhang <[email protected]>
  Type: Standard
  Status: Final
  Created: 2017-09-14
  Requires: 2, 3

Table of Contents

Abstract

This NEP describes a wallet standard that allows the wallet files to be shared between the various implementations of NEO.

Motivation

Currently, different client programs generate different wallet files. They have different file formats, different ways of storing, and different ways of encrypting. It is difficult for users to migrate between different client programs because the wallet files are not in the same format. Although migration can be achieved by exporting the private key, it is cumbersome for wallets with multiple private keys. We need an universal wallet format that allows users to migrate across all platforms safely and easily without having to change the wallet file or export the private keys.

Rationale

The wallet standard should consider both security and cross-platform compatibility. For security, we require the implementations to use the NEP-2 mechanism to encrypt or decrypt the private keys. For cross-platform, we use the JSON format to describe the wallet files, so that the contents of the wallet files can be easily recognized on each platform.

Specification

Wallet

A wallet file in JSON format has the following basic structure:

{
  "name": "MyWallet",
  "version": "1.0",
  "scrypt": {},
  "accounts": [],
  "extra": null
}

name is a label that the user has given to the wallet.

version is currently fixed at 1.0 and will be used for functional upgrades in the future.

scrypt is a ScryptParameters object which describes the parameters of the SCrypt algorithm used for encrypting and decrypting the private keys in the wallet.

accounts is an array of Account objects which describe the details of each account in the wallet.

extra is an object that is defined by the implementor of the client for storing extra data. This field can be null.

ScryptParameters

ScryptParameters object has the following structure:

{
  "n": 16384,
  "r": 8,
  "p": 8
}

n is a parameter that defines the CPU/memory cost. Must be a value 2^N.

r is a tuning parameter.

p is a tuning parameter (parallelization parameter). A large value of p can increase computational cost of SCrypt without increasing the memory usage.

Account

Account object has the following structure:

{
  "address": "AQLASLtT6pWbThcSCYU1biVqhMnzhTgLFq",
  "label": "MyAddress",
  "isDefault": true,
  "lock": false,
  "key": "6PYWB8m1bCnu5bQkRUKAwbZp2BHNvQ3BQRLbpLdTuizpyLkQPSZbtZfoxx",
  "contract": {},
  "extra": null
}

address is the base58 encoded address of the account.

label is a label that the user has given to the account.

isDefault indicates whether the account is the default change account.

lock indicates whether the account is locked by the user. The client shouldn't spend the funds in a locked account.

key is the private key of the account in NEP-2 format. This field can be null (for watch-only address or non-standard address).

contract is a Contract object which describes the details of the contract. This field can be null (for watch-only address).

extra is an object that is defined by the implementor of the client for storing extra data. This field can be null.

Contract

Contract object has the following structure:

{
  "script": "21036dc4bf8f0405dcf5d12a38487b359cb4bd693357a387d74fc438ffc7757948b0ac",
  "parameters": [],
  "deployed": false
}

script is the script code of the contract. This field can be null if the contract has been deployed to the blockchain.

parameters is an array of Parameter objects which describe the details of each parameter of the contract function. For more information about the Parameter object, see the descriptions in NEP-3: NeoContract ABI.

deployed indicates whether the contract has been deployed to the blockchain.

Backwards Compatibility

All old-format wallets should be able to be converted to this new JSON format easily. If these wallet files contain some extra data, they can be stored in the extra fileds.

Implementation