Skip to content

Commit 53ea401

Browse files
docs: overhaul README with accurate version, fixed code samples, Ethereum example
- Update version from 1.2.7 → 1.3.0 in all integration examples - Fix Maven integration (remove bintray, correct groupId) - Fix TRON sample: use ChainType.TRON instead of ChainType.BITCOIN for TRX wallet lookup - Add Ethereum transaction signing example - Add Requirements section (Java 8+, Gradle 8.5+) - Add Running Tests and Building sections - Update CI badge from Travis to GitHub Actions - Replace hardcoded '123456' passwords with 'your_password' placeholders - Use implementation instead of compile in Gradle example Co-authored-by: Galaxy <GalaxySciTech@users.noreply.github.com>
1 parent 57ed903 commit 53ea401

1 file changed

Lines changed: 67 additions & 38 deletions

File tree

README.md

Lines changed: 67 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<h1 align="center">Tokencore</h1>
22

33
<p align="center">
4-
<a href="https://travis-ci.com/galaxyscitech/tokencore">
5-
<img src="https://travis-ci.com/galaxyscitech/tokencore.svg?branch=master" alt="Build Status">
4+
<a href="https://github.com/galaxyscitech/tokencore/actions">
5+
<img src="https://github.com/galaxyscitech/tokencore/actions/workflows/ci.yml/badge.svg" alt="Build Status">
66
</a>
77
<a href="https://github.com/galaxyscitech/tokencore/issues">
88
<img src="https://img.shields.io/github/issues/galaxyscitech/tokencore.svg" alt="Issues">
@@ -34,6 +34,11 @@ Tokencore is a central component for blockchain wallet backends. It currently su
3434
- TRX, TRC20, BCH, BSV
3535
- DOGE, DASH, LTC, FILECOIN
3636

37+
## Requirements
38+
39+
- Java 8+
40+
- Gradle 8.5+ (included via wrapper)
41+
3742
## Integration
3843

3944
### Gradle
@@ -43,36 +48,28 @@ repositories {
4348
maven { url 'https://jitpack.io' }
4449
}
4550
dependencies {
46-
compile 'com.github.galaxyscitech:tokencore:1.2.7'
51+
implementation 'com.github.galaxyscitech:tokencore:1.3.0'
4752
}
4853
```
4954

5055
### Maven
5156

5257
```xml
5358
<repositories>
54-
<repository>
55-
<id>tronj</id>
56-
<url>https://dl.bintray.com/tronj/tronj</url>
57-
</repository>
5859
<repository>
5960
<id>jitpack.io</id>
6061
<url>https://jitpack.io</url>
6162
</repository>
6263
</repositories>
6364

6465
<dependency>
65-
<groupId>com.github.galaxyzxcv</groupId>
66+
<groupId>com.github.galaxyscitech</groupId>
6667
<artifactId>tokencore</artifactId>
67-
<version>1.2.7</version>
68+
<version>1.3.0</version>
6869
</dependency>
6970
```
7071

71-
## Sample Test
72-
73-
View a sample test at [Tokencore Test Sample](https://github.com/galaxyscitech/tokencore/blob/master/src/test/java/org/consenlabs/tokencore/Test.java).
74-
75-
## Usage Guide
72+
## Quick Start
7673

7774
### Initialize Identity
7875

@@ -81,12 +78,17 @@ try {
8178
Files.createDirectories(Paths.get("${keyStoreProperties.dir}/wallets"));
8279
} catch(Throwable ignored) {}
8380

84-
WalletManager.storage = new KeystoreStorage();
81+
WalletManager.storage = new KeystoreStorage() {
82+
@Override
83+
public File getKeystoreDir() {
84+
return new File("/path/to/keystore");
85+
}
86+
};
8587
WalletManager.scanWallets();
86-
String password = "123456";
88+
String password = "your_password";
8789
Identity identity = Identity.getCurrentIdentity();
8890

89-
if(identity == null) {
91+
if (identity == null) {
9092
Identity.createIdentity("token", password, "", Network.MAINNET, Metadata.P2WPKH);
9193
}
9294
```
@@ -95,23 +97,22 @@ if(identity == null) {
9597

9698
```java
9799
Identity identity = Identity.getCurrentIdentity();
98-
String password = "123456";
99-
Wallet wallet = identity.deriveWalletByMnemonics(ChainType.BITCOIN, password, MnemonicUtil.randomMnemonicCodes());
100+
String password = "your_password";
101+
Wallet wallet = identity.deriveWalletByMnemonics(
102+
ChainType.BITCOIN, password, MnemonicUtil.randomMnemonicCodes());
100103
System.out.println(wallet.getAddress());
101104
```
102105

103106
## Offline Signature
104107

105-
Offline signing refers to the process of creating a digital signature for a transaction without connecting to the internet. This method enhances security by ensuring private keys never come in contact with an online environment. Here's how you can create an offline signature with Tokencore for Bitcoin and TRON:
108+
Offline signing refers to the process of creating a digital signature for a transaction without connecting to the internet. This method enhances security by ensuring private keys never come in contact with an online environment.
106109

107110
### Bitcoin
108111

109112
1. **Set Up Transaction Details**
110113

111-
Define the details of your Bitcoin transaction, including recipient's address, change index, amount to be transferred, and the fee.
112-
113114
```java
114-
String password = "123456";
115+
String password = "your_password";
115116
String toAddress = "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9";
116117
int changeIdx = 0;
117118
long amount = 1000L;
@@ -128,39 +129,67 @@ Offline signing refers to the process of creating a digital signature for a tran
128129

129130
3. **Initialize Transaction & Sign**
130131

131-
With all the details in place, initialize the Bitcoin transaction and sign it offline.
132-
133132
```java
134-
BitcoinTransaction bitcoinTransaction = new BitcoinTransaction(toAddress, changeIdx, amount, fee, utxos);
135-
Wallet wallet = WalletManager.findWalletByAddress(ChainType.BITCOIN, "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9");
136-
TxSignResult txSignResult = bitcoinTransaction.signTransaction(String.valueOf(ChainId.BITCOIN_MAINNET), password, wallet);
137-
System.out.println(txSignResult);
133+
BitcoinTransaction bitcoinTransaction = new BitcoinTransaction(
134+
toAddress, changeIdx, amount, fee, utxos);
135+
Wallet wallet = WalletManager.findWalletByAddress(
136+
ChainType.BITCOIN, "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9");
137+
TxSignResult txSignResult = bitcoinTransaction.signTransaction(
138+
String.valueOf(ChainId.BITCOIN_MAINNET), password, wallet);
139+
System.out.println(txSignResult.getSignedTx());
138140
```
139141

140142
### TRON
141143

142144
1. **Set Up Transaction Details**
143145

144-
Define your TRON transaction details, including the sender's address, recipient's address, and amount.
145-
146146
```java
147147
String from = "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8";
148148
String to = "TF17BgPaZYbz8oxbjhriubPDsA7ArKoLX3";
149149
long amount = 1;
150-
String password = "123456";
150+
String password = "your_password";
151151
```
152152

153153
2. **Initialize Transaction & Sign**
154154

155-
Once you have the transaction details, initialize the TRON transaction and sign it offline.
156-
157155
```java
158156
TronTransaction transaction = new TronTransaction(from, to, amount);
159-
Wallet wallet = WalletManager.findWalletByAddress(ChainType.BITCOIN, "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8");
160-
TxSignResult txSignResult = transaction.signTransaction(String.valueOf(ChainId.BITCOIN_MAINNET), password, wallet);
161-
System.out.println(txSignResult);
157+
Wallet wallet = WalletManager.findWalletByAddress(
158+
ChainType.TRON, "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8");
159+
TxSignResult txSignResult = transaction.signTransaction(
160+
"mainnet", password, wallet);
161+
System.out.println(txSignResult.getSignedTx());
162162
```
163163

164-
Remember, offline signing enhances security but requires a thorough understanding of transaction construction to avoid errors.
164+
### Ethereum
165+
166+
```java
167+
EthereumTransaction tx = new EthereumTransaction(
168+
BigInteger.ZERO, // nonce
169+
BigInteger.valueOf(20_000_000_000L), // gasPrice
170+
BigInteger.valueOf(21000), // gasLimit
171+
"0xRecipientAddress", // to
172+
BigInteger.valueOf(1_000_000_000_000_000_000L), // value (1 ETH)
173+
"" // data
174+
);
175+
176+
Wallet wallet = WalletManager.findWalletByAddress(
177+
ChainType.ETHEREUM, "0xYourAddress");
178+
TxSignResult result = tx.signTransaction(
179+
String.valueOf(ChainId.ETHEREUM_MAINNET), password, wallet);
180+
System.out.println(result.getSignedTx());
181+
```
182+
183+
## Running Tests
184+
185+
```bash
186+
./gradlew test
187+
```
188+
189+
## Building
190+
191+
```bash
192+
./gradlew build
193+
```
165194

166195
> **Note**: Tokencore is a functional component for digital currency. It's primarily for learning purposes and doesn't offer a complete blockchain business suite.

0 commit comments

Comments
 (0)