Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@mintbase-js/sdk
Advanced tools
[//]: # { "title": "@mintbase-js/sdk", "order": 0 }
The core @mintbase-js/sdk
is a set of convenience wrappers around invocation of Mintbase smart contract methods.
It also exposes a low-level isomorphic execute method that can be passed raw NearContractCall
information.
In order to invoke a smart contract method, the transaction has to be signed using a public/private key pair.
There are two options, both provided from the @mintbase-js/auth module:
The easiest way to call mintbase token and market contracts are with the convenience methods.
Details such as the method name, arguments, gas supplied, deposits and some other less than convenient aspects of blockchain development will be abstracted away for you, or at least well documented in each example.
{% hint style="warning" %} This is a work in progress, please reach out to us on Telegram for support. {% endhint %}
Check back soon for details. Individual methods and documentation will start to be available as we implement in the gitbook documentation menu.
execute
You are always free to use the core execute method without the API methods, which will allow you to specify all options of the contract call.
The method will accept a single NearContractCall
object or an array of calls and determine how batch based on NearCallSigningOptions
(browser wallet, or near-api-js Account).
execute(
calls: NearContractCall | NearContractCall[],
signingOptions: NearCallSigningOptions
): Promise<void | providers.FinalExecutionOutcome>
Here is an example using the raw function call
The NearContractCall
type specifies the properties that our contract calls must specify:
{% code title="executeContractMethod.ts" overflow="wrap" lineNumbers="true" %}
import { execute, MAX_GAS, ONE_YOCTO } from '@mintbase-js/sdk';
import { getWallet } from '@mintbase-js/auth';
import type {
NearContractCall,
NearCallSigningOptions,
FinalExecutionOutcome
} from '@mintbase-js/sdk';
const call: NearContractCall = {
// the smart contract address for which we will call
// most of the time, this will be supplied as an environment variable
contractAddress: 'mytokencontract.mintbase1.near',
// the smart contract method
methodName: 'transfer',
// the arguments supplied to the method
args: { receiver_id: 'bob.near', token_id: '123' },
// how much gas you would like to send
// you will be refunded unused gas so MAX_GAS is always a safe bet
gas: MAX_GAS,
// most methods require the min amount of deposit (ONE_YOCTO) to be accepted.
// in some cases deposit amount is the amount of currency to be transfer,
deposit: ONE_YOCTO,
}
const makeSmartContractCall = async (): Promise<FinalExecutionOutcome> => {
// to better understand signing options, read the auth module docs
// to use an account directly, you have to implement this method
// const account = await authenticateAccount('mynearaccount.near');
// before the getWallet can be called, you will need to setup the components in the browser, it will throw othwerise
const wallet = await getWallet();
const sign: NearCallSigningOptions = {
// account
wallet,
}
return await execute(call, sign);
}
makeSmartContractCall()
.then((res: FinalExecutionOutcome) => console.log('got transaction result:', res))
.catch((err) => console.error('things went wrong', err));
{% endcode %}
The reason for the optional Promise<void>
return type in the execute method, is that batch methods in some [near/wallet-selector] implementations do not return transactions execution outcomes.
{% hint style="warning" %}
Should you encounter this known issue make sure you are not importing modules directly from near-api-js
, import them from @mintbase-js/sdk
instead to avoid the duplicate import.
{% endhint %}
FAQs
Core functions for Mintbase JS SDK
We found that @mintbase-js/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.