
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 peer-to-peer asset swaps on EVM-compatible networks. Enables direct and open-ended swaps of ERC20, ERC721, and ERC1155 tokens.
npm install @b3dotfun/p2pswap
User A Contract User B
| | |
|------ List Assets ------->| |
|------ Set Terms --------->| |
|------ Lock Assets ------->| |
| |<---- View Listing -------|
| |<---- Check Terms --------|
| |<---- Provide Assets -----|
| | |
| |------ Validate --------->|
| | |
|<---- Transfer Assets -----|---- Execute Swap ------->|
| | |
Initiator Contract Offerers
| | |
|------ List Assets ------->| |
|------ Lock Assets ------->| |
| |<---- View Assets --------|
| |<---- Make Offer ---------|
| |<---- Lock Assets --------|
| | |
|<---- Review Offers -------| |
| | |
|------ Accept Offer ------>| |
|<---- Transfer Assets -----|---- Execute Trade ------>|
| | |
Key Differences:
Direct Swap
Open Swap
import { createPublicClient, createWalletClient, http } from 'viem';
import { b3 } from 'viem/chains';
import { SwapSDK } from '@b3dotfun/p2pswap';
const sdk = new SwapSDK({
contractAddress: '0x...',
publicClient,
walletClient
});
// User A: Propose a swap
const { swapId } = await sdk.direct.proposeDirectSwap(
[{ // Offered assets
tokenAddress: '0x...',
amount: 1000000000000000000n,
tokenType: 'ERC20'
}],
[{ // Requested assets
tokenAddress: '0x...',
tokenId: 123n,
tokenType: 'ERC721'
}],
deadline
);
// User B: Accept the swap
await sdk.direct.acceptDirectSwap(swapId, requestedAssets);
The Open Swap feature allows users to:
import { createPublicClient, createWalletClient, http } from 'viem';
import { mainnet } from 'viem/chains';
import { SwapSDK } from '@b3dotfun/p2pswap';
const sdk = new SwapSDK({
contractAddress: '0x...',
publicClient,
walletClient
});
// User A: Create open swap
const { swapId } = await sdk.open.proposeOpenSwap(
[{ // Available assets
tokenAddress: '0x...',
tokenId: 456n,
tokenType: 'ERC721'
}],
deadline
);
// User B: View available swaps and make an offer
const { offerId } = await sdk.open.makeOfferForOpenSwap(
swapId,
[{ // Offered assets
tokenAddress: '0x...',
amount: 5000000000000000000n,
tokenType: 'ERC20'
}]
);
// User C: Make another offer for the same swap
const { offerId: secondOfferId } = await sdk.open.makeOfferForOpenSwap(
swapId,
[{ // Different offer
tokenAddress: '0x...',
tokenId: 789n,
tokenType: 'ERC721'
}]
);
// User A: View all offers for their swap
const offers = await sdk.open.getSwapOffers(swapId);
// User A: Accept their preferred offer
await sdk.open.acceptOffer(swapId, offerId);
// User C: Cancel their offer if not accepted
await sdk.open.cancelOffer(swapId, secondOfferId);
// User A: Cancel the entire swap if needed
await sdk.open.cancelOpenSwap(swapId);
Compatible with all EVM-based networks including:
For detailed documentation, visit docs.b3.fun
MIT
FAQs
SDK for P2P Asset Swap Protocol
The npm package @b3dotfun/p2pswap receives a total of 25 weekly downloads. As such, @b3dotfun/p2pswap popularity was classified as not popular.
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.