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

@okxweb3/coin-aptos

v1.0.11

Published

Aptos SDK is used to interact with the Aptos blockchain, it contains various functions can be used to web3 wallet.

Downloads

289

Readme

@okxweb3/coin-aptos

Aptos SDK is used to interact with the Aptos blockchain, it contains various functions can be used to web3 wallet.

Installation

Npm

To obtain the latest version, simply require the project using npm :

npm install @okxweb3/coin-aptos

Usage

Generate private key

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
let key = await wallet.getRandomPrivateKey();

Private key derivation

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
let mnemonic = "bean mountain minute enemy state always weekend accuse flag wait island tortoise";
let param = {
    mnemonic: mnemonic,
    hdPath: "m/44'/637'/0'/0'/0'"
};
let privateKey = await wallet.getDerivedPrivateKey(param);

Generate address

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
let params: NewAddressParams = {
    privateKey: "f4118e8a1193bf164ac2223f7d0e9c625d6d5ca19d2fbfea7c55d3c0d0284cd0312a81c872aad3a910157ca7b05e70fe2e62aed55b4a14ad033db4556c1547dc",
    addressType: "short",
};
let address = await wallet.getNewAddress(params);

Verify address

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
let p: ValidAddressParams = {
    address: "0x8e6d339ff6096080a4d91c291b297d3814ff9daa34e0f5562d4e7d442cafecdc"
};
let valid = await wallet.validAddress(p);

Transfer APTOS

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
const ts = Math.floor(Date.now()/1000) + 3000
const param: AptosParam =  {
    type: "transfer",
    base: {
        sequenceNumber: 1n,
        chainId: 32,
        maxGasAmount: 10000n,
        gasUnitPrice: 100n,
        expirationTimestampSecs: BigInt(ts),
    },
    data: {
        recipientAddress: "0x0163f9f9f773f3b0e788559d9efcbe547889500d0891fe024e782c7224defd01",
        amount: 1000,
    }
}
let signParams: SignTxParams = {
  privateKey: "f4118e8a1193bf164ac2223f7d0e9c625d6d5ca19d2fbfea7c55d3c0d0284cd0312a81c872aad3a910157ca7b05e70fe2e62aed55b4a14ad033db4556c1547dc",
  data: param
};
let tx =await wallet.signTransaction(signParams);

Transfer token-register

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
  const ts = Math.floor(Date.now()/1000) + 3000
  const param: AptosParam =  {
    type: "tokenRegister",
    base: {
      sequenceNumber: 4n,
      chainId: 32,
      maxGasAmount: 10000n,
      gasUnitPrice: 100n,
      expirationTimestampSecs: BigInt(ts),
    },
    data: {
      tyArg: "0x02961adfe972ee3c5ce70472cddd1a69803ad45d712d95e3c65480d44305d975::moon_coin::MoonCoin",
    }
  }
  let signParams: SignTxParams = {
    privateKey: "f4118e8a1193bf164ac2223f7d0e9c625d6d5ca19d2fbfea7c55d3c0d0284cd0312a81c872aad3a910157ca7b05e70fe2e62aed55b4a14ad033db4556c1547dc",
    data: param
  };
  let tx = await wallet.signTransaction(signParams);

transfer token-transfering

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
const ts = Math.floor(Date.now()/1000) + 3000
const param: AptosParam =  {
  type: "tokenTransfer",
  base: {
    sequenceNumber: 5n,
    chainId: 32,
    maxGasAmount: 10000n,
    gasUnitPrice: 100n,
    expirationTimestampSecs: BigInt(ts),
  },
  data: {
    tyArg: "0x02961adfe972ee3c5ce70472cddd1a69803ad45d712d95e3c65480d44305d975::moon_coin::MoonCoin",
    recipientAddress: "0x0163f9f9f773f3b0e788559d9efcbe547889500d0891fe024e782c7224defd01",
    amount: 1000,
  }
}
let signParams: SignTxParams = {
  privateKey: "f4118e8a1193bf164ac2223f7d0e9c625d6d5ca19d2fbfea7c55d3c0d0284cd0312a81c872aad3a910157ca7b05e70fe2e62aed55b4a14ad033db4556c1547dc",
  data: param
};
let tx = await wallet.signTransaction(signParams);

dex contract call

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
const callData = "{\n    \"function\":\"0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::scripts::swap\",\n    \"type_arguments\":[\n        \"0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::USDT\",\n        \"0xb4d7b2466d211c1f4629e8340bb1a9e75e7f8fb38cc145c54c5c9f9d5017a318::coins_extended::USDC\",\n        \"0xb4d7b2466d211c1f4629e8340bb1a9e75e7f8fb38cc145c54c5c9f9d5017a318::lp::LP<0xb4d7b2466d211c1f4629e8340bb1a9e75e7f8fb38cc145c54c5c9f9d5017a318::coins_extended::USDC, 0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::USDT>\"\n    ],\n    \"arguments\":[\n        \"0xb4d7b2466d211c1f4629e8340bb1a9e75e7f8fb38cc145c54c5c9f9d5017a318\",\n        \"1000000\",\n        \"465087\"\n    ],\n    \"type\":\"entry_function_payload\"\n}"
const moduleData = "[]"
const ts = Math.floor(Date.now()/1000) + 3000
const param: AptosParam =  {
  type: "dapp",
  base: {
    sequenceNumber: "6",
    chainId: 32,
    maxGasAmount: "10000",
    gasUnitPrice: "100",
    expirationTimestampSecs: ts.toString(),
  },
  data: {
    abi: moduleData,
    data: callData,
  }
}
let signParams: SignTxParams = {
  privateKey: "f4118e8a1193bf164ac2223f7d0e9c625d6d5ca19d2fbfea7c55d3c0d0284cd0312a81c872aad3a910157ca7b05e70fe2e62aed55b4a14ad033db4556c1547dc",
  data: param
};
let tx = await wallet.signTransaction(signParams);

Sign message

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
let param = {
    privateKey: "f4118e8a1193bf164ac2223f7d0e9c625d6d5ca19d2fbfea7c55d3c0d0284cd0312a81c872aad3a910157ca7b05e70fe2e62aed55b4a14ad033db4556c1547dc", 
    data: "aptos message"
}
let data = await wallet.signMessage(param);

offerNFT

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
const ts = Math.floor(Date.now()/1000) + 3000
const param: AptosParam =  {
  type: "offerNft",
  base: {
    sequenceNumber: "6",
    chainId: 32,
    maxGasAmount: "10000",
    gasUnitPrice: "100",
    expirationTimestampSecs: ts.toString(),
  },
  data: {
    receiver: "0xedc4410aa38b512e3173fcd1e119abb13872d6928dce0842664ad6ada1ccd28",
    creator: "0xedc4410aa38b512e3173fcd1e119abb13872d6928dce0842664ad6ada1ccd28",
    collectionName: "collect_test",
    tokenName: "nft_test",
    version: "1",
    amount: "1"
  }
}
let signParams: SignTxParams = {
  privateKey: "f4118e8a1193bf164ac2223f7d0e9c625d6d5ca19d2fbfea7c55d3c0d0284cd0312a81c872aad3a910157ca7b05e70fe2e62aed55b4a14ad033db4556c1547dc",
  data: param
};
let tx = await wallet.signTransaction(signParams);

claimNFT

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
const ts = Math.floor(Date.now()/1000) + 3000
const param: AptosParam =  {
  type: "claimNft",
  base: {
    sequenceNumber: "6",
    chainId: 32,
    maxGasAmount: "10000",
    gasUnitPrice: "100",
    expirationTimestampSecs: ts.toString(),
  },
  data: {
    sender: "0xedc4410aa38b512e3173fcd1e119abb13872d6928dce0842664ad6ada1ccd28",
    creator: "0xedc4410aa38b512e3173fcd1e119abb13872d6928dce0842664ad6ada1ccd28",
    collectionName: "collect_test",
    tokenName: "nft_test",
    version: "1"
  }
}
let signParams: SignTxParams = {
  privateKey: "f4118e8a1193bf164ac2223f7d0e9c625d6d5ca19d2fbfea7c55d3c0d0284cd0312a81c872aad3a910157ca7b05e70fe2e62aed55b4a14ad033db4556c1547dc",
  data: param
};

let tx = await wallet.signTransaction(signParams);

offerNFT_simulate

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
const ts = Math.floor(Date.now()/1000) + 3000
const param: AptosParam =  {
  type: "offerNft_simulate",
  base: {
    sequenceNumber: "6",
    chainId: 32,
    maxGasAmount: "10000",
    gasUnitPrice: "100",
    expirationTimestampSecs: ts.toString(),
  },
  data: {
    receiver: "0xedc4410aa38b512e3173fcd1e119abb13872d6928dce0842664ad6ada1ccd28",
    creator: "0xedc4410aa38b512e3173fcd1e119abb13872d6928dce0842664ad6ada1ccd28",
    collectionName: "collect_test",
    tokenName: "nft_test",
    version: "1",
    amount: "1"
  }
}
let signParams: SignTxParams = {
  privateKey: "f4118e8a1193bf164ac2223f7d0e9c625d6d5ca19d2fbfea7c55d3c0d0284cd0312a81c872aad3a910157ca7b05e70fe2e62aed55b4a14ad033db4556c1547dc",
  data: param
};
let tx = await wallet.signTransaction(signParams);

claimNFT_simulate

import {AptosWallet} from "@okxweb3/coin-aptos";

let wallet = new AptosWallet()
const ts = Math.floor(Date.now()/1000) + 3000
const param: AptosParam =  {
  type: "claimNft_simulate",
  base: {
    sequenceNumber: "6",
    chainId: 32,
    maxGasAmount: "10000",
    gasUnitPrice: "100",
    expirationTimestampSecs: ts.toString(),
  },
  data: {
    sender: "0xedc4410aa38b512e3173fcd1e119abb13872d6928dce0842664ad6ada1ccd28",
    creator: "0xedc4410aa38b512e3173fcd1e119abb13872d6928dce0842664ad6ada1ccd28",
    collectionName: "collect_test",
    tokenName: "nft_test",
    version: "1"
  }
}
let signParams: SignTxParams = {
  privateKey: "f4118e8a1193bf164ac2223f7d0e9c625d6d5ca19d2fbfea7c55d3c0d0284cd0312a81c872aad3a910157ca7b05e70fe2e62aed55b4a14ad033db4556c1547dc",
  data: param
};
let tx = await wallet.signTransaction(signParams);

License

Most packages or folder are MIT licensed, see package or folder for the respective license.