FRUITS API Document
  • FRUITS API Document
  • Java sample code
  • PHP sample code
  • Creating Unsigned Transactions
  • Create Transaction Request
  • Create Transaction Response
  • SERVER INFORMATION
    • Get Blockchain Status
    • Get My Info
    • Get State
    • Get Time
  • ACCOUNT
    • Get Account
    • Get Account Blocks
    • Get Balance
    • Send FRTS
    • Send FRTS Multi
    • Set Account Info
  • TRANSACTION
    • Broadcast Transaction
    • Calculate Full Hash
    • Get Transaction
  • BLOCK
    • Get Block
    • Get Block Id
    • Get Blocks
  • Process flowchart
    • FRTS, token send/receive flow
    • FRUITS Wallet connect flow
  • Create & Active Account
    • Coding Guidelines in Java
    • Coding Guidelines in JS
  • FRUITS Node API For Single NFT
    • Create NFT Smart Contract
    • Mint NFT
    • Transfer NFT
    • Place a sell order
    • Cancel a sell order
    • Buy NFT
    • Get NFT By URI
    • Get List of NFTs by Account
    • Get List of NFTs for sale
    • Get List of NFTs By Smart Contract
  • FRUITS Node API For multiple NFT
    • Create NFT Smart Contract
    • Mint NFT
    • Transfer NFT
    • Place a sell order
    • Cancel a sell order
    • Buy NFT
    • Get Multiple Token By Account
    • Get Multiple Token By Contract
    • Get Multiple Token By Owners
    • Get Multiple Token By Uri
Powered by GitBook
On this page
  • I. To create a new account in your client/app, you need to follow these steps:
  • II. To activate your account on FRUITS network, you need to follow these steps:
  1. Create & Active Account

Coding Guidelines in Java

PreviousFRUITS Wallet connect flowNextCoding Guidelines in JS

Last updated 1 year ago

I. To create a new account in your client/app, you need to follow these steps:

1) Install bitcoinj library via github url:

or using gradle/maven:

2) Install fruits-kit library:

  • Maven:

// Add the JitPack repository to your build file
<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
        </repository>
</repositories>

// Add the fruits-kit dependency
<dependencies>
    <dependency>
        <groupId>com.github.fruits-eco-blockchain</groupId>
        <artifactId>fruits-kit4j</artifactId>
        <version>v1.0.0</version>
    </dependency>
</dependencies>
  • Gradle:

// Add the JitPack repository to your build file
repositories {
    maven { url 'https://jitpack.io' }
}

// Add the fruits-kit dependency
dependencies {
    implementation 'com.github.fruits-eco-blockchain:fruits-kit4j:v1.0.0'
}

3) Generate your passphrase from bitcoinj library:

import org.bitcoinj.crypto.MnemonicCode;
import java.security.SecureRandom;

SecureRandom secureRandom = new SecureRandom();
byte[] entropy = new byte[16];
secureRandom.nextBytes(entropy);
MnemonicCode mnemonicCode = new MnemonicCode();

// This is a passphrase according to BIP39 standard.
// Currently we only accept passphrases according to this standard.
String passphraseMnemonic = String.join(" ", mnemonicCode.toMnemonic(entropy));

4) Generate keys, accountId address from passphrase

import fruits.kit.crypto.FruitsCrypto;
import org.bouncycastle.util.encoders.Hex;

final FruitsCrypto fruitsCrypto = FruitsCrypto.getInstance();

// passphraseMnemonic is generated above
byte[] privateKeyBytes = fruitsCrypto.getPrivateKey(passphraseMnemonic);
byte[] publicKeyBytes = fruitsCrypto.getPublicKey(privateKeyBytes);
// This key is used to sign transactions.
String privateKey = Hex.toHexString(privateKeyBytes);
// This key is used to active account
String publicKey = Hex.toHexString(publicKeyBytes);

// passphraseMnemonic is generated above
FruitsAddress fruitsAddress =
fruitsCrypto.getFruitsAddressFromPassphrase(passphraseMnemonic);

// Account Id: 4397003537557138002
String accountId = fruitsAddress.getFruitsID().getID();

// Address: FRUITS-7TG6-AUEJ-SWLX-8DW5-2R7C-27QB
String addressRS = fruitsAddress.getFullAddress();

5) After completing the above steps, you have a new account, but it does not exist in the FRUITS network. You need to call our active service according to the instructions below, then your account can be used.

II. To activate your account on FRUITS network, you need to follow these steps:

1) Call API to activator:

  • Method: POST

  • Request Body:

{
    "activeRequests": 
    [
        {
            "id": accountId, //generated above
            "publicKey": publicKey //generated above
        }
    ]
}
  • Response:

{
    "errorCode": 0,
    "message": "",
    "result": null
}

➔ errorCode = 0 means there is no error, you have successfully requested.

➔ errorCode = 1 means that an error has occurred, you need to check the information in the message.

2) After calling API, you need to wait about 2 - 5 minutes for the system to activate the account. After that time, you can check if the account is active or not by calling the following API, if not please contact us:

  • Method: GET

  • If the response has an errorCode, you have not activated it successfully, please contact us for support.

  • Otherwise, if the response has no errorCode, you have created it successfully.

URL: ( Testnet URL:)

URL: ( Testnet URL: )

https://github.com/bitcoinj/bitcoinj
https://mvnrepository.com/artifact/org.bitcoinj/bitcoinj-core/0.16.2
https://activator.fwallet.net/fruits/activator/active
https://testnet-activator.fwallet.net/fruits/activator/active
https://fwallet.net/fruits?requestType=getAccount&account=accountId
https://testnet.fwallet.net/fruits?requestType=getAccount&account=accountId