Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@chromia/bridge-client
Advanced tools
This is a client library with utilities for interacting with the Chromia Bridge.
This is a client library with utilities for interacting with the Chromia Bridge.
allowToken
function in the TokenBridge contract. This is possible to do with @chromia/bridge-client
using the built in method allowToken
:
const contractTransactionResponse = await bcl.allowToken(token);
setBlockchainRid
function in the TokenBridge contract. This is possible to do with @chromia/bridge-client
using the built in method setBlockchainRid
:
const contractTransactionResponse = await bcl.setBlockchainRid(rid);
updateValidators
function in the Validator contract.The bridge client needs an active Session
to handle all Chromia related queries and operations. In order to get an active Session
, you can set up your application with @chromia/ft4
like this:
// 1: Setup a connection to postchain through postchain-client
const pcl = await createClient({
nodeUrlPool: 'YOU_NODE_URL_POOL',
blockchainRid: 'YOUR_BLOCKCHAIN_RID',
});
// 2: Create an account
const evmKeyStore = await createWeb3ProviderEvmKeyStore(window.ethereum);
const ad = createSingleSigAuthDescriptorRegistration(
[AuthFlag.Account, AuthFlag.Transfer],
evmKeyStore.id
);
const response = await registerAccount(
pcl,
evmKeyStore,
registrationStrategy.open(ad)
);
// 3: Log in your user
const evmKeyStoreInteractor = createKeyStoreInteractor(pcl, evmKeyStore);
const accounts = await evmKeyStoreInteractor.getAccounts();
const session = await evmKeyStoreInteractor.getSession(accounts[0].id);
evmKeyStore
somewhere in your application state as some methods in @chromia/bridge-client
will require it.Now that you have your Session
object, you can use it to initialize the bridge client:
const bcl = await bridgeClient(
{ bridgeAddress: 'YOUR_BRIDGE_ADDRESS', tokenAddress: 'YOUR_TOKEN_ADDRESS' },
session,
window.ethereum
);
First, make sure that the user approves spending of tokens by the token bridge:
const approvalResponse = await bcl.approveDepositAmount(BigInt(10));
To make a deposit to the Chromia EVM bridge, you need to use the method depositToEvmBridgeContract
. Here you will need to provide the evmKeyStore
you created earlier, along with the amount
of tokens you want to bridge over.
const contractTransactionResponse = await bcl.depositToEvmBridgeContract(
BigInt(100),
evmKeyStore
);
This is all you have to do in order to bridge tokens from EVM to Chromia, if the transaction is successful the user will now have their bridged tokens on Chromia.
For the user one of two things will happen:
To do this, you will first have to call the method bridgeFromChromia
, with the amount
and the assetId
:
// Network ID does not need to be provided as it will be fetched from the provider
const transactionResponse = await bcl.bridgeFromChromia(
BigInt(10),
Buffer.from('YOUR_ASSET_ID', 'hex')
);
The previous action created a pending withdraw request, these need to be accepted by the user in order to start the withdrawal process, which is done with the requestEvmWithdraw
method. This process looks like this:
// Get all Erc20Withdraw objects
const withdrawals = await bcl.getChromiaWithdrawRequests();
// Get event proof for withdrawal
const eventProof = await bcl.getWithdrawRequestEventProof(withdrawals[0]);
// Request withdrawal
const requestedWithdraw = await bcl.requestEvmWithdraw(eventProof);
Depending on how the bridge contract has been configured, the user will have to wait X number of blocks on EVM in order to complete their withdrawal. This can be done with the getPendingWithdrawFromProof
method:
const { block_number } = await getPendingWithdrawFromProof(eventProof);
Once the block_number
has been reached on the target EVM chain, the user can withdraw their tokens:
const withdrawal = await bcl.evmWithdraw(eventProof.leaf as Buffer);
FAQs
This is a client library with utilities for interacting with the Chromia Bridge.
The npm package @chromia/bridge-client receives a total of 214 weekly downloads. As such, @chromia/bridge-client popularity was classified as not popular.
We found that @chromia/bridge-client 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.