Contact
– GalaxySciTech – Official Website
Use Cases
This serves as the exchange wallet backend. For more details, check out java-wallet.
Introduction
Tokencore is a central component for blockchain wallet backends. It currently supports the following:
- BTC, OMNI, ETH, ERC20
- TRX, TRC20, BCH, BSV
- DOGE, DASH, LTC, FILECOIN
Integration
Gradle
repositories {
maven {
url 'https://jitpack.io'
}
}
dependencies {
compile 'com.github.galaxyscitech:tokencore:1.2.7'
}
Maven
<repositories>
<repository>
<id>tronj</id>
<url>https://dl.bintray.com/tronj/tronj</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.galaxyzxcv</groupId>
<artifactId>tokencore</artifactId>
<version>1.2.7</version>
</dependency>
Sample Test
View a sample test at Tokencore Test Sample.
Usage Guide
Initialize Identity
try {
Files.createDirectories(Paths.get($keyStoreProperties.dir + "wallets"));
} catch(Throwable ignored) {
WalletManager.storage = new KeystoreStorage();
WalletManager.scanWallets();
}
String password = "123456";
Identity identity = Identity.getCurrentIdentity();
if(identity == null) {
Identity.createIdentity(token, password, null, Network.MAINNET, Metadata.P2WPKH);
}
Generate Wallet
Identity identity = Identity.getCurrentIdentity();
String password = "123456";
Wallet wallet = identity.deriveWalletByMnemonics(ChainType.BITCOIN, password, MnemonicUtil.randomMnemonicCodes());
System.out.println(wallet.getAddress());
Offline Signature
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:
Bitcoin
- Set Up Transaction Details
Define the details of your Bitcoin transaction, including recipient’s address, change index, amount to be transferred, and the fee.
String password = "123456"; String toAddress = "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9"; int changeIdx = 0; long amount = 1000L; long fee = 555L;
- Fetch UTXOs
You’ll need UTXOs (Unspent Transaction Outputs) for the transaction. Usually, these are fetched from a node or an external API.
ArrayList
utxos = new ArrayList(); - Initialize Transaction & Sign
With all the details in place, initialize the Bitcoin transaction and sign it offline.
BitcoinTransaction bitcoinTransaction = new BitcoinTransaction(toAddress, changeIdx, amount, fee, utxos); Wallet wallet = WalletManager.findWalletByAddress(ChainType.BITCOIN, "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9"); TxSignResult txSignResult = bitcoinTransaction.signTransaction(String.valueOf(ChainId.BITCOIN_MAINNET), password, wallet); System.out.println(txSignResult);
TRON
- Set Up Transaction Details
Define your TRON transaction details, including the sender’s address, recipient’s address, and amount.
String from = "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8"; String to = "TF17BgPaZYbz8oxbjhriubPDsA7ArKoLX3"; long amount = 1; String password = "123456";
- Initialize Transaction & Sign
Once you have the transaction details, initialize the TRON transaction and sign it offline.
TronTransaction transaction = new TronTransaction(from, to, amount); Wallet wallet = WalletManager.findWalletByAddress(ChainType.BITCOIN, "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8"); TxSignResult txSignResult = transaction.signTransaction(String.valueOf(ChainId.BITCOIN_MAINNET), password, wallet); System.out.println(txSignResult);
Remember, offline signing enhances security but requires a thorough understanding of transaction construction to avoid errors.
Note: Tokencore is a functional component for digital currency. It’s primarily for learning purposes and doesn’t offer a complete blockchain business suite.
Troubleshooting
If you encounter issues with Tokencore, here are some common troubleshooting ideas:
- Ensure that all dependencies are correctly added to your Gradle or Maven setup.
- Verify that the paths for any key stores or directories are correct.
- Check for any network issues if you’re fetching UTXOs or connecting wallets.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.