Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/debuggor/toncoin-sdk
https://github.com/debuggor/toncoin-sdk
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/debuggor/toncoin-sdk
- Owner: debuggor
- License: mit
- Created: 2022-03-04T02:21:46.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-04T06:34:23.000Z (almost 3 years ago)
- Last Synced: 2024-11-12T05:40:11.195Z (3 months ago)
- Language: Java
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## toncoin-sdk
toncoin java sdk, supports generating Wallet V3 (r2) addresses and offline transaction signatures.
### usage
Example:
```java
public static void main(String[] args) {
byte[] seed = Hex.decode("1091a79e7d50246479ef1ae489b33e6aba7077f64463376597fd8e3fe838d660");
KeyPair keyPair = KeyPair.fromSecretSeed(seed);
String publicKey = Hex.toHexString(keyPair.getPublicKey());long seqno = 0L;
BigDecimal value = BigDecimal.valueOf(0.01);
long amount = value.multiply(BigDecimal.valueOf(Math.pow(10, 9))).longValue();
// to address
String to = "EQC9n2Gvzo3DqokN6w8sSK_lAO7iWH8sYjewkENqN8q_BS4H";
Boolean bounced = false;
to = new Address(to).toAddressString(true, true, bounced, false);
Address toAddress = new Address(to);WalletContract contract = new WalletV3ContractR2(publicKey);
contract.setDate(new Date()); // Set the transaction time, the default is 10min valid
JSONObject object = contract.createTransferMessage(seed, toAddress, amount, seqno, "Comment", 3, false);
Cell message = object.getObject("message", Cell.class);
byte[] bytes = message.toBoc(false, true, false, 0);
System.out.println(Base64.toBase64String(bytes));
}
```## rpc
**Query address information**
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getWalletInformation", "params":{"address":"EQDnghGSSsQAiT7CXEZivwYVLQzQKRXTNahSETgw0qpxn7kA"}}' https://toncenter.com/api/v2/jsonRPC
**broadcast transaction**
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"sendBoc", "params":{"boc":"te6cckEBAgEAswAB34gBzwQjJJWIARJ9hLiMxX4MKloZoFIrpmtQpCJwYaVU4z4C1jXmAOqnbuNk7jasxZGdaT/w9pHFnGPXjqgsXSP14qqj2cPKnv3PlLxQ7/IXE3JosNnIaU7VFyz1qAcF6EAQGU1NGLsRDD4wAAAACBwBAHxCAF7PsNfnRuHVRIb1h5YkV/KAd3EsP5YxG9hIIbUb5V+CnMS0AAAAAAAAAAAAAAAAAAAAAAAAQ29tbWVudDDSr1w="}}' https://toncenter.com/api/v2/jsonRPC**block explorer**
https://tonwhales.com/explorer/address/EQDnghGSSsQAiT7CXEZivwYVLQzQKRXTNahSETgw0qpxn7kA
## notice
Some address verification may fail, low probability.