Quick start

sharkdag.js를 설치하고 실행하기 위한 방법

Install

sharkdag.js 라이브러리는 브라우저(html 코드)와 Node.js 에서 직접 사용할 수 있습니다.

Node.js 를 통한 사용방법

Node.js에 직접 사용하고자 할 경우에는 아래와 같이 명령을 실행하세요.

npm i https://github.com/dubu4-dev/shark-dag-js.git --save

브라우저(html)를 통한 사용방법

index.html 등을 만들고 sharkdag.js 스크립트 소스에 포함 시키면 됩니다.

<script src="public/js/sharkdag.min.js"></script>

코드 테스트 (Unit Test with Jest)

Jest를 이용한 유닛 테스트를 할 수 있습니다.

yarn test --verbose

사용법

웹소켓 클라이언트 생성:

const sharkdag = require('shark-dag-js');

// 기본 공식 허브에 연결 'wss://mainnet.dubu4.com/hub'
const client = new sharkdag.Client();

// 특정 허브에 연결
const client = new sharkdag.Client('wss://testnet.dubu4.com/hub');

// Connect to testnet
const options = { testnet: true };
const client = new sharkdag.Client('wss://testnet.dubu4.com/hub', options);

클라이언트 인스턴스 종료:

모든 API 메서드는 아래와 같은 패턴을 가집니다:

Transaction

유닛을 작성하고 포스팅하기 위해서는 먼저 DUBU4 월렛을 생성하고 일정량의 MO를 소유하고 있어야 합니다. 실제 sharkdag.js를 이용하여 송금 코드를 작성하기 위해서는 임시로 WIF(Wallet Import Format)를 발급받아 여기로 필요한 양의 MO + 수수료를 송금하고 sharkdag.js 라이브러리에서 WIF를 직접 호출하여 사용하도록 합니다.

Generate a random address

송금하기 샘플:

Last updated

Was this helpful?