npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@klaytn/kss-bridges-wormhole

v1.0.0

Published

Typescript and Javascript client and use-cases for wormhole

Downloads

5

Readme

Klaytn wormhole starter kit

About

Wormhole is a communication bridge between Klaytn and other top decentralized finance (DeFi) networks. Existing projects, platforms, and communities are able to move tokenized assets seamlessly across blockchains and benefit from Klaytn's high speed and low cost.

Folder Structure

  • core: it includes @wormhole-sdk and the contracts ABIs
  • use-cases: Ready-to-run code of some use-cases to call the Wormhole Rest APIs.

Installation

npm install @klaytn/kss-bridges-wormhole --save

Quick Start

BridgeSDK contains the implementation of the bridge use-cases. CoreBridgeSDK exposes methods of @certusone/wormhole-sdk to write custom methods.

import BridgeSDK from '@klaytn/kss-bridges-wormhole';
import CoreBridgeSDK from '@klaytn/kss-bridges-wormhole/core';

or

const BridgeSDK = require('@klaytn/kss-bridges-wormhole');
const CoreBridgeSDK = require('@klaytn/kss-bridges-wormhole/core');

You can run following ready-made use-cases to test

1. Token Attestation

Attests a token of one chain (source chain) to another chain (destination chain) for EVM compatible chains.

BridgeSDK.attest(config, source, destination)

NOTE: Make sure the Token to be attested is present in source chain. Native fee coins in source and destination chain in the provided privatekey account is sufficient.

Parameters

  1. Object - config
  2. Object - source
    • token - string token contract address to be attested
    • privatekey - string privatekey to perform transactions
    • rpcUrl - string blockchain rpc url
    • coreBridge - string core bridge contract address. see Testnet CoreBridge for reference.
    • tokenBridge - string token bridge contract address. see Testnet TokenBridge for reference.
    • wormholeChainId - string wormhole chainID. see Testnet WormholeChainID for reference.
  3. Object - destination
    • privatekey - string privatekey to perform transactions
    • rpcUrl - string blockchain rpc url
    • tokenBridge - string token bridge contract address. see Testnet TokenBridge for reference.
    • wormholeChainId - string wormhole chainID. see Testnet WormholeChainID for reference.

Returns

String - Deployed contract address on Destination chain

Example

const BridgeSDK = require('@klaytn/kss-bridges-wormhole');
const CoreBridgeSDK = require('@klaytn/kss-bridges-wormhole/core');

const config = { restAddress: "https://wormhole-v2-testnet-api.certus.one" };
const source = {
  token: "0x0FD3f122A9B6471928B60eeE73bF35D895C4Ee01", // Token to be attested
  privatekey: "source chain private key",
  rpcUrl: "https://api.baobab.klaytn.net:8651",
  coreBridge: "0x1830CC6eE66c84D2F177B94D544967c774E624cA",
  tokenBridge: "0xC7A13BE098720840dEa132D860fDfa030884b09A",
  wormholeChainId: "13" 
};
const destination = {
  privatekey: "destination chain private key",
  rpcUrl: "https://ethereum-goerli-rpc.allthatnode.com",
  tokenBridge: "0xF890982f9310df57d00f659cf4fd87e65adEd8d7",
  wormholeChainId: "2" 
}

console.log(CoreBridgeSDK.CHAINS); // prints the chains from @certusone/wormhole-sdk

const destinationDeployedContract = await BridgeSDK.attest(config, source, destination);

// Destination chain deployed contract
console.log(destinationDeployedContract); // 0xfdA23F910E5CE6b7C712F624DE20d9cC3A5d2122

2.Transfer Tokens

Transfer tokens from source chain to destination chain for EVM compatible chains.

BridgeSDK.transferBasic(config, source, destination, AMOUNT, IS_NATIVE)

NOTE: Make sure the tokens/coins is present in source chain. Native fee coins in source and destination chain in the provided privatekey account is sufficient.

Parameters

  1. Object - config
  2. Object - source
    • token - string token contract address. Provide if IS_NATIVE is false.
    • privatekey - string privatekey to perform transactions
    • rpcUrl - string blockchain rpc url
    • coreBridge - string core bridge contract address. see Testnet CoreBridge for reference.
    • tokenBridge - string token bridge contract address. see Testnet TokenBridge for reference.
    • wormholeChainId - string wormhole chainID. see Testnet WormholeChainID for reference.
  3. Object - destination
    • privatekey - string privatekey to perform transactions
    • rpcUrl - string blockchain rpc url
    • tokenBridge - string token bridge contract address. see Testnet TokenBridge for reference.
    • wormholeChainId - string wormhole chainID. see Testnet WormholeChainID for reference.
  4. Amount - string - Amount to be transferred.
  5. IS_NATIVE - boolean - Provide true if its a native coin transfer from source and false if its a token transfer.

Returns

Object - Transaction Object

Example

const BridgeSDK = require('@klaytn/kss-bridges-wormhole');
const CoreBridgeSDK = require('@klaytn/kss-bridges-wormhole/core');

const config = { restAddress: "https://wormhole-v2-testnet-api.certus.one" };
const source = {
  token: "0x0FD3f122A9B6471928B60eeE73bF35D895C4Ee01", // Token to be attested
  privatekey: "source chain private key",
  rpcUrl: "https://api.baobab.klaytn.net:8651",
  coreBridge: "0x1830CC6eE66c84D2F177B94D544967c774E624cA",
  tokenBridge: "0xC7A13BE098720840dEa132D860fDfa030884b09A",
  wormholeChainId: "13" 
};
const destination = {
  privatekey: "destination chain private key",
  rpcUrl: "https://ethereum-goerli-rpc.allthatnode.com",
  tokenBridge: "0xF890982f9310df57d00f659cf4fd87e65adEd8d7",
  wormholeChainId: "2" 
}
// Transfers 1 token from source chain's provided token address.
const AMOUNT = "1";
const IS_NATIVE = false;

console.log(CoreBridgeSDK.CHAINS); // prints the chains from @certusone/wormhole-sdk

const result = await BridgeSDK.transferBasic(config, source, destination, AMOUNT, IS_NATIVE);

// Transaction hash of the destination chain
console.log(result.hash);

Reference Docs: