LogoLogo
Developer DashboardMarketplaceDeveloper Discord
  • Getting Started
    • 👋Welcome to Altura
    • ➕Creating a Project
    • â›―Blockchains & Gas Fees
    • 🖞ïļMinting and Importing NFTs
      • Minting Individual NFTs
      • Importing Collections
      • Bulk Mint NFTs
      • Lazy Mint (Primary Sales)
    • 🔗Linking Your Collections
    • ðŸ’ģThe Developer Wallet
    • 🧠Smart NFTs
    • 🎁Lootboxes
    • 🔑Getting Your API Key
    • ðŸŽŪIntegrating Altura
    • ðŸ‘ĨAuthenticating Users
      • Altura Guard (Legacy)
      • Altura Guard II
        • Integration
        • REST API Demo
  • Altura Intelligence
    • 🧑‍ðŸĶēNPC Engine
      • ðŸĪĩNPC Engine +
    • 🌎World Engine
    • ðŸ’ģPlay Wallet
    • 💁Concierge
  • Marketplace
    • 🛍ïļThe Altura Marketplace
    • ðŸŽŊListing Your Game on the Altura Marketplace
    • ✅Getting Your Collections Verified
    • ðŸŽĻCreate Your Own White-Label Marketplace
  • 🌐API Reference
    • Get Endpoints
      • Verify a User's Altura Guard Code
      • Get User
      • Get Many Users
      • Get a User's Items
      • Get Item
      • Get Items
      • Get an Item's Holders
      • Get an Item's History
      • Get Collection
      • Get Collections
      • Get a User's Item Balance
      • Get a User's ERC20 Balance
      • Get a User's Native Token Balance
      • Get a User's Domain Names (Space ID)
      • Get a User From Domain Name (Space ID)
    • Developer Wallet Endpoints
      • Transfer ERC1155
      • Bulk Transfer ERC1155
      • Mint New ERC1155 NFT
      • Mint Additional Supply of ERC1155
      • Transfer ERC721
      • Transfer ERC20
      • Consume an Item (ERC1155)
    • Smart NFT Endpoints
      • Update an Item's Property
      • Add New Properties
      • Remove Properties
      • Bulk Update an Item's Properties
      • Switch an Item's Primary Image
      • Add a New Image
      • Update an Item's Name & Description
      • Update a Collection's Metadata
    • Altura Guard II
      • Connect to user wallet
      • Revoke Connection
      • Check Connection
      • Transaction Requests
        • Polling Transaction Response
        • Submitting a signature request
        • Submitting a native transaction request
        • Submitting a contract transaction request
  • ⚙ïļUnity SDK Reference
    • Installation
    • Get Methods
      • Verify a User's Altura Guard Code
      • Get User
      • Get Users
      • Get Item
      • Get Items
      • Get an Item's Holders
      • Get an Item's History
      • Get Collection
      • Get Collections
      • Get a User's Item Balance
      • Get a User's ERC20 Balance
      • Get a User's Native Token Balance
    • Schemas
  • ⚙ïļJS SDK Reference
    • Installation
    • Get Methods
      • Verify a User's Altura Guard Code
      • Get User
      • Get Many Users
      • Get a User's Items
      • Get Item
      • Get Items
      • Get an Item's Holders
      • Get an Item's History
      • Get Collection
      • Get Collections
      • Get a User's Item Balance
      • Get a User's ERC20 Balance
      • Get a User's Native Token Balance
    • Developer Wallet Methods
      • Transfer ERC1155
      • Bulk Transfer ERC1155
      • Mint Additional Supply of ERC1155
      • Transfer ERC721
      • Transfer ERC20
      • Consume an Item (ERC1155)
    • Smart NFT Endpoints
      • Update an Item's Property
      • Add new Properties
      • Remove Properties
      • Bulk Update an Item's Properties
      • Switch an Item's Primary Image
      • Add a New Image
      • Update an Item's Name & Description
      • Update a Collections Metadata
    • Altura Guard II
      • Connect to a user's wallet
      • Revoke Connection
      • Check Connection
      • Transaction Requests
        • Submitting a signature request
        • Submitting a native transaction request
        • Submitting a contract transaction request
    • Connect to Web3 Wallet
    • Schemas
Powered by GitBook
On this page
  • Import Metamask
  • Import WalletConnect
  • Get Wallet Address
  • Get Wallet Balance
  • Sign Message
  • Send Transaction
  • Get Network information
  • Get Gas Price
  • Get Fee Data
  • Get Block Number
  1. JS SDK Reference

Connect to Web3 Wallet

Use this method to allow users to login via Metamask or WalletConnect.

Import Metamask

import { MetamaskConnector } from "@altura/altura-js/lib/connector";

const wallet = new MetamaskConnector(window.ethereum);

wallet.connect(); // connect to the wallet

Import WalletConnect

First install WalletConnect web3-provider :

npm i @walletconnect/web3-provider

Now import WalletConnect web3-provider and WalletConnectConnector from Altura:

import { WalletConnectConnector } from "@altura/altura-js/lib/connector";
import WalletConnectProvider from "@walletconnect/web3-provider";

Now, instantiate your WalletConnect web3-provider using the following options: Infura or Custom RPC mapping

import WalletConnectProvider from "@walletconnect/web3-provider";

//  Create WalletConnect Provider
const provider = new WalletConnectProvider({
  infuraId: "27e484dcd9e3efcfd25a83a78777cdf1",
});

//  Enable session (triggers QR Code modal)
await provider.enable();
import WalletConnectProvider from "@walletconnect/web3-provider";

//  Create WalletConnect Provider
const provider = new WalletConnectProvider({
  rpc: {
    1: "https://mainnet.mycustomnode.com",
    3: "https://ropsten.mycustomnode.com",
    100: "https://dai.poa.network",
    // ...
  },
});

//  Enable session (triggers QR Code modal)
await provider.enable();

Now integrate it with WalletConnectConnector:

const wallet = new WalletConnectConnector(provider);

Get Wallet Address

const walletAddress = await wallet.address();
console.log(walletAddress);

Get Wallet Balance

const walletAddress = await wallet.address();
console.log(walletAddress);

Sign Message

try {
    await wallet.sign("Hi Altura!");
} catch (error) {
    console.log("Denied the sign", error);
}

Send Transaction

try {
    const tx = {
        to: "0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",
        // `function addr(namehash("ricmoo.eth")) view returns (address)`
        data: "0x3b3b57debf074faa138b72c65adbdcfb329847e4f2c04bde7f7dd7fcad5a52d2f395a558",
    };
    await wallet.sendTransaction(tx);
} catch (error) {
    console.log("Error on sending transaction", error);
}

Get Network information

const getNetworkData = await wallet.getNetwork();
console.log(getNetworkData);

Get Gas Price

const getGasPrice = await wallet.getGasPrice();
console.log(getGasPrice);

Get Fee Data

const getFeeData = await wallet.getFeeData();
console.log(getFeeData);

Get Block Number

const getBlockNumber = await wallet.getBlockNumber();
console.log(getBlockNumber);
PreviousSubmitting a contract transaction requestNextSchemas

Last updated 2 years ago

⚙ïļ