npm install @oberton/sdk
<script src="https://cdn.jsdelivr.net/npm/@oberton/sdk@1.0.7/docs/index.js"></script>
import Oberton from '@oberton/sdk';
// if use CDN script, Oberton is accesible over window.Oberton
const optionalOptions = {
skipPromoDialog: false, // show dialog with the link to webstore, if user doesn't have the Oberton extension installed
};
const oberton = new Oberton('net.ton.dev', optionalOptions);
returns tmpId{String}, that is passed as an argument, when transaction sent or failed
oberton.sendTokens({
to: '0:dc5612b47ef94b8eed1358f2d118757c66e2a120e9d3e623b148710a50661f20',
amount: 0.5,
});
oberton.sendTokens({
to: '0:dc5612b47ef94b8eed1358f2d118757c66e2a120e9d3e623b148710a50661f20',
amount: 0.5,
payloadType: 'comment',
comment: 'Hello World',
});
oberton.sendTokens({
to: '0:dc5612b47ef94b8eed1358f2d118757c66e2a120e9d3e623b148710a50661f20',
amount: 0.5,
payloadType: 'function',
functionName: 'someFunctionName',
abiJSON: '{...}',
functionParams: '{...}',
});
oberton.sendTokens({
to: '0:dc5612b47ef94b8eed1358f2d118757c66e2a120e9d3e623b148710a50661f20',
amount: 0.5,
payloadType: 'payload',
payload: '...',
});
Destroys oberton instance, with all related event listeners
oberton.destroy();
import Oberton from '@oberton/sdk';
const oberton = new Oberton();
oberton
/* extension is not installed or unreacheable
* or transaction failed to sent */
.on('error', (data) => console.log('error', data))
/* transaction has been sent */
.on('transactionSent', (data) => console.log('transactionSent', data)) // transactionSent, provides details from the @tonclient SDK
/* transaction failed */
.on('transactionFailed', (data) => console.log('transactionFailed', data))
/* any response from an extension, included errors and transactions events */
.on('response', (data) => console.log('response', data));
oberton.sendTokens({
to: '0:4b0cc91b506e5cff29eb1cb64f0b543e0d15ac6e3a3743ec462a711abbc7aa36',
amount: 0.5,
payloadType: 'comment',
comment: 'Hello World2',
});