Giter Club home page Giter Club logo

java-sdk's Introduction

BNB Beacon Chain Java SDK

The BNB Beacon Chain Java SDK works as a lightweight Java library for interacting with the BNB Beacon Chain. It provides a complete API coverage, and supports synchronous and asynchronous requests. It includes the following core components:

  • crypto - core cryptographic functions.
  • amino encoding - amino (protobuf-like) encoding and decoding of transactions.
  • client - implementations of API rest client, supporting synchronous and asynchronous access to BNB Beacon Chain's REST APIs.
  • wallet - management of accounts, including seed and encrypted mnemonic generation.

How to get

  1. Add the JitPack repository to your project's pom.xml:
        <repositories>
            <repository>
                <id>jitpack.io</id>
                <url>https://jitpack.io</url>
            </repository>
        </repositories>
    
  2. Add the dependency:
    <dependency>
        <groupId>com.github.bnb-chain</groupId>
        <artifactId>java-sdk</artifactId>
        <version>Tag</version>
    </dependency>
    

Protobuf

The protobuf-maven-plugin is used in this SDK. It is a plugin that integrates protocol buffers compiler (protoc) into Maven lifecycle. The Plugin generates Java source files from .proto (protocol buffer definition) files for this project by running mvn compile.

These Java source files will be packaged into the final artifact and referenced as imports from the dependent projects or modules by running mvn clean package.

More details please refer to https://github.com/xolstice/protobuf-maven-plugin

API

For examples, please check the wiki.

Testing

All new code changes should be covered with unit tests. You can see the existing test cases here.

Contributing

Contributions to the BNB Beacon Chain Java SDK are welcome. Please ensure that you have tested the changes with a local client and have added unit test coverage for your code.

java-sdk's People

Contributors

andacaydin avatar apshenkin avatar chainwhisper avatar darren-liu avatar dependabot[bot] avatar dreiz3r avatar endercrypto avatar fitzlu avatar fletcher142 avatar fletcherman avatar forcodedancing avatar francis-l-20230331 avatar jiangkai avatar jiangkai-rq avatar jjos2372 avatar mitjag avatar notatestuser avatar pythonberg1997 avatar qinshaohui avatar randyahx avatar rumeelhussainbnb avatar shawn-qin-20230331 avatar unclezoro avatar vladmelnyk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-sdk's Issues

support Decoding

Thank to great chain and nice supporting lib.
And you guys have plan for decoding?

Add support for quoteOrderQty field for NewOrder message

According to the official changelog for the binance api

https://github.com/binance-exchange/binance-official-api-docs/blob/master/CHANGELOG.md

the field quoteOrderQty should be enabled for all symbols. If supported for binance dex (I am not 100% sure of this), it would be great if the java sdk could support that as well. I tried to add it myself, but the messages are serialized with amino and I am not aware of the fieldnumber for this new field (see dex.proto). Could you give some insights on this? Is the field supported for binance dex as well?

Supporting the quoteOrderQty would be great as currently there is no easy way to sell a fixed amount of a quote asset.

mvn compilation failure

master分支:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /binance/java-sdk/target/generated-sources/protobuf/grpc-java/types/ABCIApplicationGrpc.java:[20,18] 找不到符号
符号: 类 Generated
位置: 程序包 javax.annotation
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

获取高度交易失败

获取某个高度的交易,返回为空。但是这个高度上面是有交易的。

@Test
    public void getBlockTransactions(){
        List<Transaction> result = nodeClient.getBlockTransactions(149611021L);
        System.out.println("size :" + result.size());
        for (Transaction transaction : result) {
            System.out.println(transaction.toString());
        }
    }

Error on getting transactions by block height

binanceDexApiNodeClient.getBlockTransactions(153204081))

Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "type" (class com.binance.dex.api.client.domain.jsonrpc.TxResult$Event), not marked as ignorable (one known property: "attributes"])
 at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 22, column: 24] (through reference chain: com.binance.dex.api.client.domain.jsonrpc.JsonRpcResponse["result"]-com.binance.dex.api.client.domain.jsonrpc.BlockInfoResult["txs"]->java.util.ArrayList[0]-com.binance.dex.api.client.domain.jsonrpc.BlockInfoResult$Transaction["tx_result"]-com.binance.dex.api.client.domain.jsonrpc.TxResult["events"]->java.util.ArrayList[1]-com.binance.dex.api.client.domain.jsonrpc.TxResult$Event["type"])

Can't use api in gradle

Hi,
I try to get your API via android gradle and get an error while it try to sync
ERROR: Failed to resolve: com.binance.dex.api:binance-dex-api-client:1.0.0

the line that I added to gradle dependencies is:
implementation 'com.binance.dex.api:binance-dex-api-client:1.0.0'

Transfer Problem

When we initiate a transfer and send a broadcast, if the “sync” is set to false, the result is normal.just like :[{"hash":"6BFBE9F41946F23546165176A98ADC037EC110DCAC661F3917E7A045325B61B0","ok":true}]

but if the "sync" is set to true,return 400.

what is problem?

invalid address

Hello everyone

this issue is related to javascript_SDK and java_SDK if https://testnet.binance.org use javascript_sdk .

i use this private key to get address : 90335b9d2153ad1a9799a3ccc070bd64b4164e9642ee1dd48053c33f9a3a05e9

but returned address in java_sdk and https://testnet.binance.org is differ
address from JAVA_SDK : bnc1hgm0p7khfk85zpz5v0j8wnej3a90w7098fpxyh
address from testnet.binanace.org : tbnb1hgm0p7khfk85zpz5v0j8wnej3a90w709zzlffd

i know bnc or tbnb is hrp and there is 1hgm0p7khfk85zpz5v0j8wnej3a90w709 in both

java.net.SocketTimeoutException: timeout

java.lang.RuntimeException: java.net.SocketTimeoutException: timeout
at com.binance.dex.api.client.impl.BinanceDexApiNodeClientImpl.getNodeInfo(BinanceDexApiNodeClientImpl.java:49) ~[binance-dex-api-client-1.0.0.jar!/:na]
....
Caused by: java.net.SocketTimeoutException: timeout
at okio.Okio$4.newTimeoutException(Okio.java:232) ~[okio-1.15.0.jar!/:na]
at okio.AsyncTimeout.exit(AsyncTimeout.java:285) ~[okio-1.15.0.jar!/:na]
... 17 common frames omitted
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.read(SocketInputStream.java:204) ~[na:1.8.0_161]
at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_161]
at okio.Okio$2.read(Okio.java:140) ~[okio-1.15.0.jar!/:na]
at okio.AsyncTimeout$2.read(AsyncTimeout.java:237) ~[okio-1.15.0.jar!/:na]
... 38 common frames omitted

When I perform the API times wrong, binanceDexNodeApi.Transfer (transfer, NodeWallet, options, true) has been an error, but Blockchain Explorer query execution transfer success. BinanceDexNodeApi.GetNodeInfo() and occasionally as errors

I used the official demon to query the wallet address information incorrectly

Exception in thread "main" com.binance.dex.api.client.BinanceDexApiException: BinanceDexApiError[code=400,message=decoding bech32 failed: checksum failed. Expected a955xp, got 07f2d2.]
at com.binance.dex.api.client.BinanceDexApiClientGenerator.executeSync(BinanceDexApiClientGenerator.java:82)
at com.binance.dex.api.client.impl.BinanceDexApiRestClientImpl.getAccount(BinanceDexApiRestClientImpl.java:77)
at TestBinance.main(TestBinance.java:17)

image

How to get all transactions in a block?

https://testnet-explorer.binance.org/block/29848066
I found block 29848066 of the test net has 118 transactions, but getBlockTransactions only get 30 transactions. How to get all of them?

How to get transaction fee?

Transaction transaction = binanceDexNodeApi.getTransaction("01277C397DFD27E8B59BDECB7B4EE8F9BA6C4E7FCA73F9B6630DEB61C0305B5B");

Hi! The above code can't get transaction fee. Is there a way to get the transaction fee?
And what's the meaning of sequence in account?
What is source and data in TransactionOption?

walletconnect problem

why user the walletconnect library in andorid wallet.

Scan login and balance transfer were ok.

but the buy and sell transaction has a problem, your website always send the same message to the phone.unable to stop.

I can't judge what caused the problem.

And after balance transfer success , try buy and sell transaction again ,was normal .

thanks.

com.binance.dex.api.proto not available

When I tried to utilize the client API, I found com.binance.dex.api.proto is not available. Hence the project can't be compiled properly.

POM file does not seem to include it either.

Am I missing anything here?

Update protobuf dependency version

I am getting below warnings when use #111

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/Users/.../.gradle/caches/modules-2/files-2.1/com.google.protobuf/protobuf-java/3.6.1/d06d46ecfd92ec6d0f3b423b4cd81cb38d8b924/protobuf-java-3.6.1.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Solved by upgrading below dependency:

com.google.protobuf:protobuf-java:3.15.6

Could not find artifact org.ethereum:ethereumj-core error

Trying to install v. 1.1.0

[ERROR] Failed to execute goal on project binance-dex-api-client: Could not resolve dependencies for project com.binance.dex.api:binance-dex-api-client:jar:1.1.0: Could not find artifact org.ethereum:ethereumj-core:jar:1.12.0-RELEASE in central (https://repo.maven.apache.org/maven2) -> [Help 1

Bech32 format?

How do I convert an ETH address to a Bech32 address to request the project's interface?
For example: '0x810c73180147ab5b22e94a3a109a22354ca1d09e' convert 'tbnb1syx8xxqpg744kghffgappx3zx4x2r5y7v8ajmy' kind of address.

Please add jar files shaded with all dependencies in the releases section.

I'm tired of maven projects with has errors like this:
[INFO] -------------< com.binance.dex.api:binance-dex-api-client >------------- [INFO] Building binance-dex-api-client 1.1.2 [INFO] --------------------------------[ jar ]--------------------------------- [WARNING] The POM for org.ethereum:ethereumj-core:jar:1.12.0-RELEASE is missing, no dependency information available [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.845 s [INFO] Finished at: 2021-11-28T07:03:15+01:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project binance-dex-api-client: Could not resolve dependencies for project com.binance.dex.api:binance-dex-api-client:jar:1.1.2: org.ethereum:ethereumj-core:jar:1.12.0-RELEAS>[ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Adding jar files in the Releases will solve this problem.

Documentation

Is there any proper documentation for this project anywhere?

BinanceDexApiError[code=404,message=account not found]

I have completed the addition of binan intelligent chain test network on metamask wallet, and I have generated the address of the response and exported the private key. I can execute the code to remove the error, what is the problem?

BinanceDexApiRestClient client = BinanceDexApiClientFactory.newInstance().newRestClient(BinanceDexEnvironment.TEST_NET.getBaseUrl());
Wallet wallet = new Wallet("e73e281c42264c5609729e57cc922e3c97a7d40bf90a3cf4ede1f1ade5296cee",BinanceDexEnvironment.TEST_NET);
client.getAccount(wallet.getAddress());

Error is as follows:
image

[WARNING] The POM for org.ethereum:ethereumj-core:jar:1.12.0-RELEASE is missing, no dependency information available

[WARNING] The POM for org.ethereum:ethereumj-core:jar:1.12.0-RELEASE is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.914 s
[INFO] Finished at: 2021-10-14T17:10:20+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project binance-dex-api-client: Could not resolve dependencies for project com.binance.dex.api:binance-dex-api-client:jar:1.1.2: Failure to find org.ethereum:ethereumj-core:jar:1.12.0-RELEASE in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Discontinued

I think this is an evidence for everyone here and it should be added into the README.
The repos of some libraries are dead and the last update has been made 12 months ago.

新创建的钱包交易问题

在测试环境生成了一个新的钱包,生成了一个新的address。

然后用有bnb余额的账号往这个账号发起转账,会报错。

显示AddressFormatException$InvalidChecksum: Checksum does not validate

在Bech32.class 里面
if (!verifyChecksum(hrp, values)) throw new AddressFormatException.InvalidChecksum();

校验不过去

想知道是什么原因

测试的钱包的address 为:tbnb1njcnva6rdjwhv6y6zvxkyptqnpge4h9f4h2qxw

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.