Skip to content

Commit 8b1f513

Browse files
committed
docs: rewrite README with full English integration guide
1 parent 454e849 commit 8b1f513

8 files changed

Lines changed: 989 additions & 931 deletions

File tree

README.md

Lines changed: 118 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,37 @@
1-
<h1 align="center">Tokencore</h1>
2-
3-
<p align="center">
4-
<strong>Multi-chain cryptocurrency wallet core library for Java</strong>
5-
</p>
6-
7-
<p align="center">
8-
<a href="https://github.com/galaxyscitech/tokencore/actions">
9-
<img src="https://github.com/galaxyscitech/tokencore/actions/workflows/ci.yml/badge.svg" alt="Build Status">
10-
</a>
11-
<a href="https://jitpack.io/#galaxyscitech/tokencore">
12-
<img src="https://jitpack.io/v/galaxyscitech/tokencore.svg" alt="JitPack">
13-
</a>
14-
<a href="https://github.com/galaxyscitech/tokencore/issues">
15-
<img src="https://img.shields.io/github/issues/galaxyscitech/tokencore.svg" alt="Issues">
16-
</a>
17-
<a href="https://github.com/galaxyscitech/tokencore/pulls">
18-
<img src="https://img.shields.io/github/issues-pr/galaxyscitech/tokencore.svg" alt="Pull Requests">
19-
</a>
20-
<a href="https://github.com/galaxyscitech/tokencore/graphs/contributors">
21-
<img src="https://img.shields.io/github/contributors/galaxyscitech/tokencore.svg" alt="Contributors">
22-
</a>
23-
<a href="LICENSE">
24-
<img src="https://img.shields.io/github/license/galaxyscitech/tokencore.svg" alt="License">
25-
</a>
26-
</p>
27-
28-
<p align="center">
29-
<a href="#supported-chains">Supported Chains</a> &nbsp;&bull;&nbsp;
30-
<a href="#quick-start">Quick Start</a> &nbsp;&bull;&nbsp;
31-
<a href="#integration">Integration</a> &nbsp;&bull;&nbsp;
32-
<a href="#offline-signing">Offline Signing</a> &nbsp;&bull;&nbsp;
33-
<a href="#contact">Contact</a>
34-
</p>
1+
# Tokencore
352

36-
---
37-
38-
## Introduction
3+
Tokencore is a Java multi-chain wallet core library for exchange backends, custody systems, and wallet services.
394

40-
Tokencore is a lightweight Java library that provides core wallet functionality for multiple blockchains. It handles HD wallet derivation, encrypted keystore management, and offline transaction signing — making it the ideal building block for exchange backends and custodial wallet services.
5+
## What Tokencore provides
416

42-
For a complete exchange wallet backend built on top of Tokencore, see [java-wallet](https://github.com/galaxyscitech/java-wallet).
7+
- Multi-chain address generation
8+
- HD wallet derivation and mnemonic workflows
9+
- Encrypted keystore management
10+
- Offline transaction signing for major chain families
4311

44-
## Supported Chains
12+
Supported chains include:
13+
- **EVM**: Ethereum
14+
- **Bitcoin family**: Bitcoin, Litecoin, Dogecoin, Dash, Bitcoin Cash, Bitcoin SV
15+
- **Others**: TRON, Filecoin, EOS
4516

46-
| Chain | Token Standards | Features |
47-
|-------|----------------|----------|
48-
| **Bitcoin** | BTC, OMNI | UTXO management, SegWit (P2WPKH) |
49-
| **Ethereum** | ETH, ERC-20 | Offline signing, nonce management |
50-
| **TRON** | TRX, TRC-20 | Transaction signing |
51-
| **Bitcoin Cash** | BCH | CashAddr format |
52-
| **Bitcoin SV** | BSV | Transaction signing |
53-
| **Litecoin** | LTC | Transaction signing |
54-
| **Dogecoin** | DOGE | Transaction signing |
55-
| **Dash** | DASH | Transaction signing |
56-
| **Filecoin** | FIL | Transaction signing |
17+
---
5718

5819
## Requirements
5920

60-
- **Java** 8 or higher
61-
- **Gradle** 8.5+ (included via wrapper, no manual install needed)
21+
- Java 8+
22+
- Gradle wrapper included (`./gradlew`)
23+
24+
---
6225

63-
## Integration
26+
## Install
6427

6528
### Gradle
6629

6730
```gradle
6831
repositories {
6932
maven { url 'https://jitpack.io' }
7033
}
34+
7135
dependencies {
7236
implementation 'com.github.galaxyscitech:tokencore:1.3.0'
7337
}
@@ -77,148 +41,144 @@ dependencies {
7741

7842
```xml
7943
<repositories>
80-
<repository>
81-
<id>jitpack.io</id>
82-
<url>https://jitpack.io</url>
83-
</repository>
44+
<repository>
45+
<id>jitpack.io</id>
46+
<url>https://jitpack.io</url>
47+
</repository>
8448
</repositories>
8549

8650
<dependency>
87-
<groupId>com.github.galaxyscitech</groupId>
88-
<artifactId>tokencore</artifactId>
89-
<version>1.3.0</version>
51+
<groupId>com.github.galaxyscitech</groupId>
52+
<artifactId>tokencore</artifactId>
53+
<version>1.3.0</version>
9054
</dependency>
9155
```
9256

93-
## Quick Start
57+
---
9458

95-
### 1. Initialize Keystore & Identity
59+
## Quick start (runnable)
9660

9761
```java
98-
WalletManager.storage = new KeystoreStorage() {
99-
@Override
100-
public File getKeystoreDir() {
101-
return new File("/path/to/keystore");
102-
}
103-
};
104-
WalletManager.scanWallets();
62+
import org.consenlabs.tokencore.foundation.utils.MnemonicUtil;
63+
import org.consenlabs.tokencore.wallet.*;
64+
import org.consenlabs.tokencore.wallet.model.*;
10565

106-
String password = "your_password";
107-
Identity identity = Identity.getCurrentIdentity();
66+
import java.io.File;
10867

109-
if (identity == null) {
110-
identity = Identity.createIdentity(
111-
"token", password, "", Network.MAINNET, Metadata.P2WPKH);
112-
}
113-
```
68+
public class QuickStart {
69+
public static void main(String[] args) {
70+
WalletManager.storage = () -> new File("./keystore");
71+
WalletManager.scanWallets();
11472

115-
### 2. Derive a Wallet
73+
String password = "UseAStrongPassword_123";
74+
Identity identity = Identity.getCurrentIdentity();
75+
if (identity == null) {
76+
identity = Identity.createIdentity("main", password, "", Network.MAINNET, Metadata.P2WPKH);
77+
}
11678

117-
```java
118-
Identity identity = Identity.getCurrentIdentity();
119-
Wallet wallet = identity.deriveWalletByMnemonics(
120-
ChainType.BITCOIN, "your_password", MnemonicUtil.randomMnemonicCodes());
121-
System.out.println(wallet.getAddress());
79+
Wallet ethWallet = identity.deriveWalletByMnemonics(
80+
ChainType.ETHEREUM,
81+
password,
82+
MnemonicUtil.randomMnemonicCodes()
83+
);
84+
85+
Wallet btcWallet = identity.deriveWalletByMnemonics(
86+
ChainType.BITCOIN,
87+
password,
88+
MnemonicUtil.randomMnemonicCodes()
89+
);
90+
91+
System.out.println("ETH address: " + ethWallet.getAddress());
92+
System.out.println("BTC address: " + btcWallet.getAddress());
93+
}
94+
}
12295
```
12396

124-
## Offline Signing
97+
---
12598

126-
Offline signing creates a digital signature without ever exposing private keys to an online environment.
99+
## Common usage
127100

128-
### Bitcoin
101+
### 1) Import wallet from private key
129102

130103
```java
131-
// 1. Define transaction parameters
132-
String toAddress = "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9";
133-
int changeIdx = 0;
134-
long amount = 1000L;
135-
long fee = 555L;
136-
137-
// 2. Collect UTXOs (from your node or a third-party API)
138-
ArrayList<BitcoinTransaction.UTXO> utxos = new ArrayList<>();
139-
140-
// 3. Build and sign
141-
BitcoinTransaction bitcoinTransaction = new BitcoinTransaction(
142-
toAddress, changeIdx, amount, fee, utxos);
143-
Wallet wallet = WalletManager.findWalletByAddress(
144-
ChainType.BITCOIN, "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9");
145-
TxSignResult txSignResult = bitcoinTransaction.signTransaction(
146-
String.valueOf(ChainId.BITCOIN_MAINNET), "your_password", wallet);
147-
System.out.println(txSignResult.getSignedTx());
104+
Metadata metadata = new Metadata();
105+
metadata.setChainType(ChainType.ETHEREUM);
106+
metadata.setSource(Metadata.FROM_PRIVATE);
107+
metadata.setNetwork(Network.MAINNET);
108+
109+
Wallet wallet = WalletManager.importWalletFromPrivateKey(
110+
metadata,
111+
"4c0883a69102937d6231471b5dbb6204fe512961708279f14a15c89a7e5a5c3c",
112+
"password123",
113+
true
114+
);
148115
```
149116

150-
### Ethereum
117+
### 2) Import wallet from mnemonic
151118

152119
```java
153-
EthereumTransaction tx = new EthereumTransaction(
154-
BigInteger.ZERO, // nonce
155-
BigInteger.valueOf(20_000_000_000L), // gasPrice
156-
BigInteger.valueOf(21_000), // gasLimit
157-
"0xRecipientAddress", // to
158-
BigInteger.valueOf(1_000_000_000_000_000_000L), // value (1 ETH)
159-
"" // data
120+
Metadata metadata = new Metadata();
121+
metadata.setChainType(ChainType.DOGECOIN);
122+
metadata.setSource(Metadata.FROM_MNEMONIC);
123+
metadata.setNetwork(Network.MAINNET);
124+
metadata.setSegWit(Metadata.NONE);
125+
126+
Wallet wallet = WalletManager.importWalletFromMnemonic(
127+
metadata,
128+
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
129+
BIP44Util.DOGECOIN_MAINNET_PATH,
130+
"password123",
131+
true
160132
);
161-
162-
Wallet wallet = WalletManager.findWalletByAddress(
163-
ChainType.ETHEREUM, "0xYourAddress");
164-
TxSignResult result = tx.signTransaction(
165-
String.valueOf(ChainId.ETHEREUM_MAINNET), "your_password", wallet);
166-
System.out.println(result.getSignedTx());
167133
```
168134

169-
### TRON
135+
### 3) Find wallet by mnemonic (BTC-family friendly)
170136

171137
```java
172-
String from = "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8";
173-
String to = "TF17BgPaZYbz8oxbjhriubPDsA7ArKoLX3";
174-
175-
TronTransaction transaction = new TronTransaction(from, to, 1L);
176-
Wallet wallet = WalletManager.findWalletByAddress(ChainType.TRON, from);
177-
TxSignResult result = transaction.signTransaction(
178-
"mainnet", "your_password", wallet);
179-
System.out.println(result.getSignedTx());
138+
Wallet wallet = WalletManager.findWalletByMnemonic(
139+
ChainType.DOGECOIN,
140+
Network.MAINNET,
141+
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
142+
BIP44Util.DOGECOIN_MAINNET_PATH,
143+
Metadata.NONE
144+
);
180145
```
181146

182-
## Build & Test
183-
184-
```bash
185-
# Build the library
186-
./gradlew build
147+
### 4) Export keystore and recover by keystore
187148

188-
# Run the test suite
189-
./gradlew test
149+
```java
150+
String keystoreJson = WalletManager.exportKeystore(wallet.getId(), "password123");
151+
Wallet found = WalletManager.findWalletByKeystore(ChainType.ETHEREUM, keystoreJson, "password123");
190152
```
191153

192-
## Project Structure
154+
---
193155

194-
```
195-
src/main/java/org/consenlabs/tokencore/
196-
├── wallet/
197-
│ ├── Identity.java # HD identity management
198-
│ ├── Wallet.java # Wallet abstraction
199-
│ ├── WalletManager.java # Wallet lifecycle & discovery
200-
│ ├── address/ # Chain-specific address generation
201-
│ ├── keystore/ # Encrypted keystore implementations
202-
│ ├── model/ # ChainType, ChainId, Metadata, etc.
203-
│ ├── network/ # Bitcoin-fork network parameters
204-
│ ├── transaction/ # Offline signing per chain
205-
│ └── validators/ # Address & key validation
206-
└── foundation/
207-
├── crypto/ # AES, KDF, hashing primitives
208-
├── utils/ # Mnemonic, numeric, byte helpers
209-
└── rlp/ # RLP encoding (Ethereum)
210-
```
156+
## Security recommendations
211157

212-
## License
158+
- Never log or print private keys, mnemonics, or decrypted keystore payloads.
159+
- Keep signing in isolated/offline environments whenever possible.
160+
- Use strong passwords and avoid hardcoded secrets.
161+
- Consider HSM/KMS for production secret governance.
162+
- Enforce strict access controls around keystore files.
213163

214-
This project is licensed under the [GNU General Public License v3.0](LICENSE).
164+
---
215165

216-
## Contact
166+
## Typical errors
217167

218-
- **Telegram**: [t.me/GalaxySciTech](https://t.me/GalaxySciTech)
219-
- **Website**: [galaxy.doctor](https://galaxy.doctor)
220-
- **GitHub Issues**: [Report a bug](https://github.com/galaxyscitech/tokencore/issues/new)
168+
- `password_incorrect`
169+
- `mnemonic_length_invalid`
170+
- `mnemonic_word_invalid`
171+
- `invalid_mnemonic_path`
172+
- `unsupported_chain`
173+
- `private_key_address_not_match`
221174

222175
---
223176

224-
> **Disclaimer**: Tokencore is a functional component for digital currency operations. It is intended primarily for learning and development purposes and does not provide a complete blockchain business solution. Use at your own risk.
177+
## Build and test
178+
179+
```bash
180+
./gradlew test
181+
./gradlew build
182+
```
183+
184+
CI runs on Java 8/11/17 via GitHub Actions.

0 commit comments

Comments
 (0)