
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@b3dotfun/p2pswap
Advanced tools
A TypeScript SDK for executing peer-to-peer asset swaps across different blockchains.
npm install tran-p2pswap
import { createPublicClient, createWalletClient, http } from 'viem';
import { CrossChainSwapSDK } from 'tran-p2pswap';
import { mainnet, arbitrum } from 'viem/chains';
import { CONTRACT_ADDRESSES } from 'tran-p2pswap';
// Initialize SDK
const sdk = new CrossChainSwapSDK({
sourceChain: {
contractAddress: CONTRACT_ADDRESSES.BASE_SEPOLIA.address,
chainId: mainnet.id,
publicClient: createPublicClient({
chain: mainnet,
transport: http()
})
},
targetChain: {
contractAddress: CONTRACT_ADDRESSES.B3_TESTNET.address,
chainId: arbitrum.id,
publicClient: createPublicClient({
chain: arbitrum,
transport: http()
})
},
walletClient // Your viem wallet client
});
// Create cross-chain trade
const { sessionId } = await sdk.createTrade(
takerAddress,
[{ // Maker assets on source chain
contractAddress: '0xTOKEN1',
amount: 1000000000000000000n,
assetType: 0, // ERC20
chainId: mainnet.id
}],
[{ // Taker assets on target chain
contractAddress: '0xTOKEN2',
amount: 5000000000000000000n,
assetType: 0, // ERC20
chainId: arbitrum.id
}],
arbitrum.id
);
// Watch trade status
sdk.watchTrade(sessionId, (status) => {
console.log('Trade status:', status);
});
import { CrossChainRelayer, CONTRACT_ADDRESSES } from 'tran-p2pswap';
const relayer = new CrossChainRelayer({
sourceChain: {
contractAddress: CONTRACT_ADDRESSES.BASE_SEPOLIA.address,
chainId: mainnet.id,
publicClient: sourceClient
},
targetChain: {
contractAddress: CONTRACT_ADDRESSES.B3_TESTNET.address,
chainId: arbitrum.id,
publicClient: targetClient
},
encryptedKey: 'your-encrypted-key',
secretKey: 'your-secret-key',
sourceAddress: CONTRACT_ADDRESSES.BASE_SEPOLIA.address,
targetAddress: CONTRACT_ADDRESSES.B3_TESTNET.address
});
// Execute cross-chain trade
await relayer.executeTradeAcrossChains(sessionId);
// Maker locks assets on source chain
const makerLockHash = await sdk.lockAssets(
sessionId,
makerAssets,
sourceChainId
);
// Taker locks assets on target chain
const takerLockHash = await sdk.lockAssets(
sessionId,
takerAssets,
targetChainId
);
// Relayer creates trade after assets are locked
const tradeHash = await relayer.createTrade(
sessionId,
maker,
taker,
makerAssets,
takerAssets,
targetChainId
);
// Relayer executes the trade
await relayer.executeTradeAcrossChains(sessionId);
// Users can unlock their assets if trade fails
await sdk.unlockAssets(sessionId, userAddress, chainId);
import { CrossChainSwapSDK } from 'tran-p2pswap';
import { CrossChainRelayer } from 'tran-p2pswap';
// Initialize SDK for users
const sdk = new CrossChainSwapSDK({
sourceChain: {
contractAddress: CONTRACT_ADDRESSES.BASE_SEPOLIA.address,
chainId: mainnet.id,
publicClient: sourceClient
},
targetChain: {
contractAddress: CONTRACT_ADDRESSES.B3_TESTNET.address,
chainId: arbitrum.id,
publicClient: targetClient
},
walletClient
});
// Initialize Relayer
const relayer = new CrossChainRelayer({
sourceChain: config.sourceChain,
targetChain: config.targetChain,
encryptedKey: process.env.RELAYER_KEY,
secretKey: process.env.SECRET_KEY,
sourceAddress: CONTRACT_ADDRESSES.BASE_SEPOLIA.address,
targetAddress: CONTRACT_ADDRESSES.B3_TESTNET.address
});
// Custom sessionId (from frontend/backend)
const sessionId = 123n;
try {
// Step 1: Users lock their assets
await sdk.lockAssets(sessionId, makerAssets, sourceChainId);
await sdk.lockAssets(sessionId, takerAssets, targetChainId);
// Step 2: Relayer creates trade
await relayer.createTrade(
sessionId,
maker,
taker,
makerAssets,
takerAssets,
targetChainId
);
// Step 3: Relayer executes trade
await relayer.executeTradeAcrossChains(sessionId);
// Monitor status
sdk.watchTrade(sessionId, (status) => {
console.log('Trade status:', status);
});
} catch (error) {
// Users can unlock their assets if something fails
await sdk.unlockAssets(sessionId, userAddress, chainId);
throw error;
}
try {
await sdk.lockAssets(sessionId, assets, chainId);
} catch (error) {
if (error instanceof ValidationError) {
console.error('Asset validation failed:', error);
} else if (error instanceof ChainError) {
await sdk.unlockAssets(sessionId, userAddress, chainId);
}
}
[Link to detailed API documentation]
Copyright © 2025 NPC Labs, Inc. All rights reserved.
FAQs
SDK for P2P Asset Swap Protocol
We found that @b3dotfun/p2pswap demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.