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

owlto-sdk

v0.2.5

Published

Owlto-Sdk is a library used to bridge token between multiple chains

Downloads

123

Readme

owlto-sdk

Owlto-Sdk is a library used to bridge token between multiple chains

Install

# Use yarn
yarn add owlto-sdk

# Or use npm
npm install owlto-sdk --save

Quickstart

For example, to bridge USDC from Base to Scroll

import * as owlto from "owlto-sdk";

const options: owlto.BridgeOptions = {}
let bridge = new owlto.Bridge(options);

const result = await bridge.getBuildTx(
    "USDC", //token name
    "BaseMainnet", //from chain name
    "ScrollMainnet",// to chain name
    "1", // value
    "0xa5E56D455BF247C475D752721Ba35A0c85Df81Dc", // from address
    "0xa5E56D455BF247C475D752721Ba35A0c85Df81Dc", // to address
);

//initialize your wallet
//...

if (result.txs.approveBody) {
    const tx = await wallet.sendTransaction(result.txs.approveBody as ethers.TransactionRequest);
    await tx.wait(); 
}

const tx = await wallet.sendTransaction(result.txs.transferBody as ethers.TransactionRequest);
await tx.wait(); 

const receipt = await bridge.waitReceipt(tx.hash)
console.log(receipt)

For more details, check the example/bridge_usdc folder.

Bridge options

1.chainNameMapping (Map<string, string> | optional)

Map your chain names to Owlto chain names.

For example, if you named Base Mainnet as "Base", you can set chainNameMapping["Base"] = "BaseMainnet".

Then you can use "Base" as chain name in every function of bridge.

Get build tx

const result = await bridge.getBuildTx(
    "USDC", //token name
    "BaseMainnet", //from chain name
    "ScrollMainnet",// to chain name
    "1", // value
    "0xa5E56D455BF247C475D752721Ba35A0c85Df81Dc", // from address
    "0xa5E56D455BF247C475D752721Ba35A0c85Df81Dc", // to address
);

//result:
{
 ...
  networkType: 1; //
  txs: any; //actual transactions need to be sent to from chain, see the following details
}

The txs contains the transactions user should send to from chain when bridging.

1.Evm

  • txs.approveBody
    The approve transaction, if any, should be sent first.
  • txs.transferBody
    The actual transfer transaction.

2.Starknet

TODO

3.Solana

TODO

Get receipt

  1. bridge.waitReceipt(fromChainHash: string)

  2. bridge.getReceipt(fromChainHash: string)

hash is the transfer transaction hash previously describe.

waitReceipt wait for the bridge process to be done. Throw error if the hash is not found for 1 minute or failed

getReceipt get the bridge process status, Throw error if hash is not found, bridge in progress or failed.

Get pair info

  1. bridge.getPairInfo(tokenName: string, fromChainName: string, toChainName: string)

  2. bridge.getAllPairInfos()

A pair consists of three component: token name, from chain name, to chain name.

You can only bridge supported pairs

Http Api Documentation

Please visit: https://owlto.finance/bridge_api/v1/swagger/index.html .