Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@magic-sdk/extension-icon
Advanced tools
npm i magic-sdk @magic-sdk/extension-icon
Setup IconExtension with magic-sdk
import { Magic } from 'magic-sdk';
import { IconExtension } from '@magic-sdk/extension-icon';
const magic = new Magic('YOUR_API_KEY', {
extensions: [
new IconExtension({
rpcUrl: 'icon rpc url'
})
]
});
// or
const magic = new Magic('YOUR_API_KEY', {
extensions: {
icon: new IconExtension({
rpcUrl: 'icon rpc url'
})
}
});
See the developer documentation to learn how you can master the Magic SDK in a matter of minutes.
Using getAccount function to get Icon public address for current user.
const publicAddress = await magic.icon.getAccount();
console.log('icon public address', publicAddress);
Build the transaction object using builder class.
/* Build `IcxTransaction` instance for sending ICX. */
const txObj = new IconBuilder.IcxTransactionBuilder()
.from("hxe4837d3b902dcaf9abe529f5584489c28d8b4621")
.to("hxe4837d3b902dcaf9abe529f5584489c28d8b4621")
.value(IconAmount.of(0.5, IconAmount.Unit.ICX).toLoop())
.stepLimit(IconConverter.toBigNumber(100000))
.nid(IconConverter.toBigNumber(3))
.nonce(IconConverter.toBigNumber(1))
.version(IconConverter.toBigNumber(3))
.timestamp((new Date()).getTime() * 1000)
.build();
/* Build `MessageTransaction` instance for sending data. */
const txObj = new IconBuilder.MessageTransactionBuilder()
.from('hxe4837d3b902dcaf9abe529f5584489c28d8b4621')
.to('hxe4837d3b902dcaf9abe529f5584489c28d8b4621')
.stepLimit(IconConverter.toBigNumber(1000000))
.nid(IconConverter.toBigNumber(3))
.nonce(IconConverter.toBigNumber(1))
.version(IconConverter.toBigNumber(3))
.timestamp((new Date()).getTime() * 1000)
.data(IconConverter.fromUtf8('Hello'))
.build();
/* Build `DeployTransaction` instance for deploying SCORE. */
const txObj = new DeployTransactionBuilder()
.from('hxe4837d3b902dcaf9abe529f5584489c28d8b4621')
.to('cx0000000000000000000000000000000000000000')
.stepLimit(IconConverter.toBigNumber(2100000000))
.nid(IconConverter.toBigNumber(3))
.nonce(IconConverter.toBigNumber(1))
.version(IconConverter.toBigNumber(3))
.timestamp((new Date()).getTime() * 1000)
.contentType('application/zip')
.content(`0x${content}`)
.params({
initialSupply: IconConverter.toHex('100000000000'),
decimals: IconConverter.toHex(18),
name: 'StandardToken',
symbol: 'ST',
})
.build();
/* Build `CallTransaction` instance for executing SCORE function. */
const txObj = new IconBuilder.CallTransactionBuilder()
.from('hxe4837d3b902dcaf9abe529f5584489c28d8b4621')
.to('cxd1602bde1d4b2b4facc8673c661c5e59e6ac20b4')
.stepLimit(IconConverter.toBigNumber('2000000'))
.nid(IconConverter.toBigNumber('3'))
.nonce(IconConverter.toBigNumber('1'))
.version(IconConverter.toBigNumber('3'))
.timestamp((new Date()).getTime() * 1000)
.method('hello')
.params({})
By passing txObj instance to magic.icon.sendTransaction()
method, it will automatically sign the transaction with current user and
generate transaction object including signature, then send to ICON node.
const txhash = await magic.icon.sendTransaction(txObj);
console.log('transaction result', txhash);
window.open(`https://bicon.tracker.solidwallet.io/transaction/${txhash}`)
FAQs
magic icon extension
The npm package @magic-sdk/extension-icon receives a total of 0 weekly downloads. As such, @magic-sdk/extension-icon popularity was classified as not popular.
We found that @magic-sdk/extension-icon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.