
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@parallelmarkets/token
Advanced tools
The Parallel Identity (PID) Token is a non-transferrable, non-fungible token (NFT) that links real world individual and business identities with Ethereum wallet addresses. The PID Token provides accreditation, Know Your Customer (KYC), and international sanctions information in the form of a ERC-721 compatible token.
The PID Token has a number of features:
See our Developer Docs for more information.
You can access PID Token information either directly on-chain on the Ethereum Mainnet or via one of the Web3 JavaScript libraries.
Here's a quick example example of usage on-chain to determine if a Token holder (individual or business) is currently accredited and free from sanctions.
import "@parallelmarkets/token/contracts/IParallelID.sol";
contract MyContract {
// This is the address on Mainnet. For testing in the sandbox environment, use the
// Rinkeby contract at 0x0F2255E8aD232c5740879e3B495EA858D93C3016
address PID_CONTRACT = "0x9ec6232742b6068ce733645AF16BA277Fa412B0A";
function isSanctionsSafe(address subject) returns (bool) {
// Get a handle for the Parallel Identity Token contract
IParallelID pid = IParallelID(PID_CONTRACT);
// It's possible a subject could have multiple tokens issued over time - check
// to see if any are currently monitored and safe from sanctions
for (uint256 i = 0; i < pid.balanceOf(subject); i++) {
uint256 tokenId = pid.tokenOfOwnerByIndex(subject, i);
if (pid.isSanctionsSafe(tokenId)) return true;
}
return false;
}
function currentlyAccredited(address subject) returns (bool) {
// Get a handle for the Parallel Identity Token contract
IParallelID pid = IParallelID(PID_CONTRACT);
// It's possible a subject could have multiple tokens issued over time - check
// to see if any have an "accredited" trait and were minted in the last 90 days
// (US regulation says accreditation certification only lasts 90 days)
for (uint256 i = 0; i < pid.balanceOf(subject); i++) {
uint256 tokenId = pid.tokenOfOwnerByIndex(subject, i);
bool recent = pid.mintedAt(tokenId) >= block.timestamp - 90 days;
bool accredited = pid.hasTrait(tokenId, "accredited");
if (recent && accredited) return true;
}
return false;
}
}
This example uses the ethers.js library.
import { utils, Contract } from 'ethers'
const abi = [
"function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)",
"function balanceOf(address owner) view returns (uint256 balance)",
"function hasTrait(uint256 tokenId, string memory trait) view returns (bool)",
"function isSanctionsSafe(uint256 tokenId) view returns (bool)"
]
// Address on the Rinkeby test network
const PID_CONTRACT = "0x6737fAA302d607e0e3B06C51E3b5D28c5624F96A"
const contract = new Contract(PID_CONTRACT, abi, provider)
const isSanctionsSafe = (address) => {
for (let i = 0; i < contract.balanceOf(address); i++) {
const tokenId = contract.tokenOfOwnerByIndex(address, i)
if (contract.isSanctionsSafe(tokenId)) return true
}
return false
}
const currentlyAccredited = (address) => {
const ninetyDaysAgo = ((new Date()).getTime() / 1000) - (90 * 86400)
for (let i = 0; i < contract.balanceOf(address); i++) {
const tokenId = contract.tokenOfOwnerByIndex(address, i)
const recent = contract.mintedAt(tokenId) >= ninetyDaysAgo
const accredited = contract.hasTrait(tokenId, "accredited")
if (recent && accredited) return true
}
return false
}
We use Hardhat for contract building / testing.
Just run:
> pnpm i
This will run all tests / linters:
> pnpm test
Use this to see what current costs are for contract calls:
> OPTIMIZE=true REPORT_GAS=true pnpm exec hardhat test
Ensure the network you'd like to deploy to is configured in hardhat.config.js
, then run:
> OPTIMIZE=true pnpm exec hardhat run --network <network name> scripts/deploy.js
Edit the scripts/mint.js
file with the address of the contract and token recipient, then run:
> pnpm exec hardhat run --network <network name> scripts/mint.js
Note - this is just for testing; production token minting is done via the recipientMint
function.
After deploying, run:
pnpm exec hardhat verify --network <network name> <contract address>
This will verify the contract on Etherscan (so everyone can see the source code).
FAQs
The Parallel Markets Identity Token (PID)
We found that @parallelmarkets/token demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.