Releases: wpdas/naxios
Releases · wpdas/naxios
v1.3.0
Wallet API Reference [New Feature]
accountId
: Main/first signed-in account ID in the accounts list.
Utils [New Features]
buildTransaction
The buildTransaction
method is useful when you need to build a contract's Transaction body, mainly when you want to make multiple contract calls. E.g.:
import { buildTransaction } from '@wpdas/naxios'
import { contractApi } from './web3Api'
// Using the default instance's contract
const transactionA = buildTransaction('set_greeting', { args: { greeting: 'Hello my dear!' } })
const transactionB = buildTransaction('set_age', { args: { age: 22 } })
// Using diff contract
const transactionC = buildTransaction('update_state', {
receiverId: 'my-state-contract.testnet',
args: { allowed: true },
})
// Optional
const callbackUrl = 'https://my-page.com/callback-success'
// [payable]
contractApi.callMultiple([transactionA, transactionB, transactionC], callbackUrl).then(() => console.log('Done!'))
validateNearAddress
This is used to check if an address is a valid NEAR address.
import { validateNearAddress } from '@wpdas/naxios'
console.log(validateNearAddress('fake.near')) // true
console.log(validateNearAddress('fake.nears')) // false
console.log(validateNearAddress('fake.testnet')) // true
console.log(validateNearAddress('fake')) // false
calculateDepositByDataSize
Calculate required deposit for data being stored. (~0.00001N per byte) with a bit extra for buffer
import { calculateDepositByDataSize } from '@wpdas/naxios'
const myData = { age: 22, name: 'user name' }
console.log(calculateDepositByDataSize(myData)) // 0.00087 Near (not yocto NEAR)
v1.2.1
v1.2.0
- added
contract.callMultiple(...)
feature: Call multiple methods that changes the contract s state
As well as the call
, you will need to pay for every request you make. This is going to change data and store it within the blockchain.
import naxios, { buildTransaction } from "@wpdas/naxios";
const contractApi = new naxios({
contractId: CONTRACT_ID,
network: "testnet",
}).contractApi();
// Using the default instance's contract
const transactionA = buildTransaction('set_greeting', { args: { greeting: 'Hello my dear!' } })
const transactionB = buildTransaction('set_age', { args: { age: 22 } })
// Using diff contract
const transactionC = buildTransaction('update_state', {
receiverId: 'my-state-contract.testnet',
args: { allowed: true },
})
// Optional
const callbackUrl = 'https://my-page.com/callback-success'
// [payable]
contractApi.callMultiple([transactionA, transactionB, transactionC], callbackUrl).then(() => console.log('Done!'))
v1.1.1
v1.1.0
- Added
getContractApi
andgetWalletApi
features
Invoking a Contract / Wallet API anytime with different setup:
// Invoking a Contract API
import { getContractApi } from '@wpdas/naxios'
// New contract instance
const contract = await getContractApi({
contractId: ANOTHER_CONTRACT_ID,
network: 'testnet',
})
const response = await contract.view('get_users', {
args: { limit: 5 },
})
// Invoking a Wallet API
import { getWalletApi } from '@wpdas/naxios'
// New wallet instance
const walletApi = await getWalletApi({
contractId: ANOTHER_CONTRACT_ID,
network: 'testnet',
})
// Open up the Signin Wallet Modal
walletApi.signInModal()