Skip to content

Commit

Permalink
Fix V3
Browse files Browse the repository at this point in the history
  • Loading branch information
liw committed Sep 15, 2023
1 parent 9efd094 commit a42737d
Show file tree
Hide file tree
Showing 11 changed files with 2,016 additions and 1,209 deletions.
466 changes: 249 additions & 217 deletions Avalanche SDK.md

Large diffs are not rendered by default.

466 changes: 249 additions & 217 deletions BinanceSmart SDK.md

Large diffs are not rendered by default.

487 changes: 487 additions & 0 deletions Ethereum SDK.md

Large diffs are not rendered by default.

466 changes: 249 additions & 217 deletions EthereumClassic SDK.md

Large diffs are not rendered by default.

466 changes: 249 additions & 217 deletions Klaytn SDK.md

Large diffs are not rendered by default.

466 changes: 249 additions & 217 deletions Polygon SDK.md

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# JAVA REST API SDK for BLOCKSDK V3
[![@BLOCKSDK on Facebook](https://img.shields.io/badge/facebook-%40BLOCKSDK-blue.svg)](https://www.facebook.com/blocksdk)
![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)

__BlockSDK JAVA__에 오신 것을 환영합니다. 이 저장소에는 BlockSDK의 JAVA SDK와 REST API용 샘플이 포함되어 있습니다.

## 지원중인 블록체인 네트워크
비트코인 , 라이트코인 , 비트코인 캐시 , 웹후크 는 V2버전 에서 지원되고 있습니다.
```
1.이더리움
2.클레이튼
3.바이낸스 스마트 체인
4.폴리곤
5.아발란체
6.이더리움 클래식
```
## 개발자 문서
* [BlockSDK REST API V3 문서](https://documenter.getpostman.com/view/20292093/Uz5FKwxw)
* [BlockSDK REST API V2 문서](https://dojava-v2.blocksdk.com/ko/#fa255f0ccc)
* [BLOCKSDK JAVA SDK V3 문서](https://github.com/Block-Chen/blocksdk-net/wiki)

## 시작하기

### Maven
```xml
<dependency>
<groupId>io.github.block-chen</groupId>
<artifactId>blocksdk-java</artifactId>
<version>3.0.0</version>
</dependency>
```
### Gradle
```groovy
implementation 'io.github.block-chen:blocksdk-java:3.0.0'
```

## 코드 샘플

### 이더리움 테스트넷 클라이언트 생성
```java
Ethereum Client = new Ethereum("YOU_TLKEN");
```

### 이더리움 메인넷 클라이언트 생성
```java
Ethereum Client = new Ethereum("YOU_TLKEN", "https://mainnet-api.blocksdk.com");
```

### 이더리움 블록체인 정보 가져오기
```java
Map<String, Object> data = Client.GetBlockchainInfo().join();
System.out.println(data);
```

### 이더리움 특정 컨트렉트 NFT 목록 가져오기
```java
Map<String, Object> data = new HashMap<>();
data.put("contract_address", "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b");
data.put("offset", "0");
data.put("limit", "10");

Map<String, Object> result = Client.GetSingleNfts(data).join();
System.out.println(result);
```
1 change: 0 additions & 1 deletion blocksdk-java.iml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java/com" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
Expand Down
152 changes: 124 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,127 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.blocksdk</groupId>
<artifactId>blocksdk-java</artifactId>
<version>1.0</version>

<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230618</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/main/java/blocksdk</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<modelVersion>4.0.0</modelVersion>

<!-- Project Metadata -->
<name>BlockSDK Java Library</name>
<description>A Java SDK for blockchain services</description>
<url>https://github.com/Block-Chen/blocksdk-java</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<developers>
<developer>
<id>block-chen</id>
<name>BlockSDK</name>
<email>support@blocksdk.com</email>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/Block-Chen/blocksdk-java.git</connection>
<developerConnection>scm:git:ssh://github.com/Block-Chen/blocksdk-java.git</developerConnection>
<url>https://github.com/Block-Chen/blocksdk-java</url>
</scm>
<groupId>io.github.block-chen</groupId>
<artifactId>blocksdk-java</artifactId>
<version>3.0.0</version>

<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230618</version>
</dependency>
</dependencies>

<build>

<!-- Plugins -->
<plugins>
<!-- Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

<!-- Source Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Javadoc Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- GPG Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>

<!-- Distribution Management -->
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/releases</url>
</repository>
</distributionManagement>

</project>
11 changes: 6 additions & 5 deletions src/main/java/blocksdk/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public Base(String chainName, String apiToken, String endpoint, String version)
}

public CompletableFuture<Map<String, Object>> request(String method, String path) {
return request(method, path, Collections.<String, String>emptyMap());
return request(method, path, Collections.<String, Object>emptyMap());
}

public CompletableFuture<Map<String, Object>> request(String method, String path, Map<String, String> data) {
public CompletableFuture<Map<String, Object>> request(String method, String path, Map<String, Object> data) {
CompletableFuture<Map<String, Object>> future = CompletableFuture.supplyAsync(() -> {
String url = this.endpoint + "/" + this.version + "/" + this.chainName + path;
StringBuffer response = new StringBuffer();
Expand All @@ -39,10 +39,10 @@ public CompletableFuture<Map<String, Object>> request(String method, String path
try {
if ("GET".equals(method)) {
StringBuilder query = new StringBuilder();
for (Map.Entry<String, String> entry : data.entrySet()) {
for (Map.Entry<String, Object> entry : data.entrySet()) {
query.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
query.append("=");
query.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
query.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8")); // Object를 문자열로 변환
query.append("&");
}
if (query.length() > 0) {
Expand All @@ -59,7 +59,8 @@ public CompletableFuture<Map<String, Object>> request(String method, String path
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
OutputStream os = con.getOutputStream();
os.write(data.toString().getBytes());
JSONObject json = new JSONObject(data); // Map을 JSON으로 변환
os.write(json.toString().getBytes());
os.flush();
os.close();
}
Expand Down
Loading

0 comments on commit a42737d

Please sign in to comment.