Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@fuseio/fusebox-web-sdk
Advanced tools
Fuse Wallet SDK now has a JS implementation, making it even easier to integrate blockchain technology into your mobile apps.
The FuseBox TS SDK is a set of tools for creating, managing, and engaging with FuseBox TS SDK in client applications. FuseBox TS SDK lets users create smart contract wallets(Based on ERC-4337) associated with each user's Externally Owned Account (EOA) that provide added security compared to traditional EOAs with a single private key. With FuseBox TS SDK, users can deposit funds that no one else can control and withdraw at any time.
Using FuseBox TS SDK provides several benefits, including:
The SDK is designed to make it easy for developers to create, manage, and engage with FuseBox TS SDK in their applications. The SDK provides pre-built functions and utilities, allowing developers to interact with FuseBox TS SDK securely and efficiently.
import { FuseSDK } from "@fuseio/fusebox-web-sdk";
import { ethers } from 'ethers';
// Create a project: https://console.fuse.io/build
const apiKey = 'YOUR_PUBLIC_API_KEY';
const credentials = new ethers.Wallet("PRIVATE_KEY");
const fuseSDK = await FuseSDK.init(apiKey, credentials);
The FuseBox TS SDK provides several features that allow developers to create, manage, and engage with FuseBox TS SDK in their applications. Some of the key features include:
Gets the address of the wallet created.
console.log(`Smart contract wallet address: ${fuseSDK.wallet.getSender()}`);
Send transactions, including ERC20 and NFT transfers and interaction with arbitrary smart contracts.
const tokenAddress = "YOUR_TOKEN";
const to = "RECEIVER_ADDRESS";
const amount = parseUnits('10000', DECIMAL); //Amount should be set in WEI. `DECIMAL` should be a numeric value
const data = Uint8Array.from([]);
const res = await fuseSDK.transferToken(
tokenAddress,
to,
amount,
data
);
console.log(`UserOpHash: ${res.userOpHash}`);
console.log(`Waiting for transaction...`);
const ev = await res.wait();
console.log(`Transaction hash: https://explorer.fuse.io/tx/${ev?.transactionHash}`);
The process of grouping multiple transactions into a single batch to be processed together. This is often done to optimize processing time and reduce transaction fees.
// Approve and transfer in a single batch
const approveCallData = ContractUtils.encodeERC20ApproveCall(
spender,
amount
) as unknown as Uint8Array;
const calls = [
{
to: tokenAddress,
value: BigInt(0),
data: approveCallData,
},
{
to: spender,
value: BigInt(0),
data: callData,
},
];
const res = await fuseSDK.executeBatch(calls, txOptions);
console.log(`UserOpHash: ${res.userOpHash}`);
console.log(`Waiting for transaction...`);
const ev = await res.wait();
console.log(`Transaction hash: https://explorer.fuse.io/tx/${ev?.transactionHash}`);
Sponsored transactions are the ability to pay for another user’s transaction fees. To do this, the Fuse operator must enable the sponsored feature in his project and deposit some funds into the paymaster contract. The SDK provides a middleware to check if the project is sponsored and the amount of funds available for sponsoring.
To use this feature, you must first initialize the SDK with the withPaymaster
parameter set to true
.
import { FuseSDK } from "@fuseio/fusebox-web-sdk";
import { ethers } from 'ethers';
const apiKey = 'YOUR_PUBLIC_API_KEY';
const credentials = new ethers.Wallet("PRIVATE_KEY");
const fuseSDK = await FuseSDK.init(apiKey, credentials, { withPaymaster: true });
The SDK provides a module for staking. This module allows users to stake their tokens and earn rewards.
Currently, the SDK supports staking for the following tokens: Native Fuse & VoltToken
const stakingOptions = await fuseSDK.stakingModule.getStakingOptions(); // Get staking options
const nativeTokenAddress = Variables.NATIVE_TOKEN_ADDRESS;
const res = await fuseSDK.stakeToken(
new StakeRequestBody({
accountAddress: fuseSDK.wallet.getSender(),
tokenAmount: '0.01',
tokenAddress: nativeTokenAddress,
})
);
console.log(`UserOpHash: ${res?.userOpHash}`);
console.log('Waiting for transaction...');
const ev = await res?.wait();
console.log(`Transaction hash: https://explorer.fuse.io/tx/${ev?.transactionHash}`);
Smart Wallet can buy and sell popular cryptocurrencies like Bitcoin and Ethereum, Stable-coins. Behind the scenes, it uses voltage.finance decentralized exchange.
const nativeTokenAddress = Variables.NATIVE_TOKEN_ADDRESS;
const usdcTokenAddress = '0x28C3d1cD466Ba22f6cae51b1a4692a831696391A';
const res = await fuseSDK.swapTokens(
new TradeRequest(
nativeTokenAddress,
usdcTokenAddress,
parseUnits('1', 18),
true,
),
);
console.log(`UserOpHash: ${res?.userOpHash}`);
console.log('Waiting for transaction...');
const ev = await res?.wait();
console.log(`Transaction hash: https://explorer.fuse.io/tx/${ev?.transactionHash}`);
User op cannot be replaced: fee too low.
If you're getting the User op cannot be replaced: fee too low
error, it means that the gas price you set is too low. You can increase the gas price by setting the TxOptions
parameter when sending a transaction. To replace an user operation, a new user operation must have at least 10% higher maxPriorityFeePerGas
and 10% higher maxPriorityFeePerGas
than the one in the user operation mempool.
To replace the user operation, the new gas price must be at least 10% higher.
const tokenAddress = "YOUR_TOKEN";
const to = "RECEIVER_ADDRESS";
const amount = parseUnits('10000', DECIMAL); //Amount should be set in WEI. `DECIMAL` should be a numeric value
const data = Uint8Array.from([]);
const res = await fuseSDK.transferToken(
tokenAddress,
to,
amount,
data,
{
withRetry: true,
feeIncrementPercentage: 11,
}
);
console.log(`UserOpHash: ${res.userOpHash}`);
console.log(`Waiting for transaction...`);
const ev = await res.wait();
console.log(`Transaction hash: https://explorer.fuse.io/tx/${ev?.transactionHash}`);
The FuseBox TS SDK works only on the Fuse & Fuse Sparknet networks, an EVM based chain L1 blockchain. Support for other blockchains is planned for the future.
If you have any questions or feedback, please get in touch with our support team at support@fuse.io.
[0.3.9]
TimeFrame
enum:
hour
, day
, and all
valuesyear
valuehour
, day
, and all
from the TimeFrame
enum may affect existing code that relies on these values.FAQs
Fuse Wallet SDK now has a JS implementation, making it even easier to integrate blockchain technology into your mobile apps.
The npm package @fuseio/fusebox-web-sdk receives a total of 0 weekly downloads. As such, @fuseio/fusebox-web-sdk popularity was classified as not popular.
We found that @fuseio/fusebox-web-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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.