Yaci Provider
Custom Cardano devnet to tailor your devnet needs with a builtin indexer and custom viewer for devnet
Yaci DevKit is a development tool designed for rapid and efficient Cardano blockchain development. It allows developers to create and destroy custom Cardano devnets in seconds, providing fast feedback loops and simplifying the iteration process.
Get started:
import { YaciProvider } from "@meshsdk/core";
const provider = new YaciProvider('<YACI_URL>', '<OPTIONAL_ADMIN_URL>');
Get data from URL
You can fetch any data from the blockchain by providing the URL path.
await provider.get('/addresses/addr_test1qpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0uafhxhu32dys6pvn6wlw8dav6cmp4pmtv7cc3yel9uu0nq93swx9/transactions')
Fetch Account Info
Obtain information about a specific stake account.
await provider.fetchAccountInfo('stake_test1uzw5mnt7g4xjgdqkfa80hrk7kdvds6sa4k0vvgjvlj7w8eskffj2n')
Fetch Address Assets
Fetch assets from an address.
await provider.fetchAddressAssets('addr_test1qpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0uafhxhu32dys6pvn6wlw8dav6cmp4pmtv7cc3yel9uu0nq93swx9')
Fetch Address UTxOs
Fetch UTxOs from address
await provider.fetchAddressAssets(
'addr_test1qpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0uafhxhu32dys6pvn6wlw8dav6cmp4pmtv7cc3yel9uu0nq93swx9'
);
Fetch assets from address
Fetch assets given an address
await provider.fetchAddressAssets(
'addr_test1qpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0uafhxhu32dys6pvn6wlw8dav6cmp4pmtv7cc3yel9uu0nq93swx9',
);
Fetch Address UTxOs
Fetch UTxOs controlled by an address.
await provider.fetchAddressUTxOs('addr_test1qpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0uafhxhu32dys6pvn6wlw8dav6cmp4pmtv7cc3yel9uu0nq93swx9')
Optionally, you can filter UTXOs containing a particular asset
by providing asset, where it is the concatenation of policy ID and asset.
await fetchAddressUTxOs(address: string, asset?: string)
Fetch Address UTxOs
Fetch UTxOs from address
await provider.fetchAddressUTxOs(
'addr_test1qpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0uafhxhu32dys6pvn6wlw8dav6cmp4pmtv7cc3yel9uu0nq93swx9'
);
Fetch UTxOs with Asset
Fetch UTxOs from address with asset
await provider.fetchAddressUTxOs(
'addr_test1qpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0uafhxhu32dys6pvn6wlw8dav6cmp4pmtv7cc3yel9uu0nq93swx9',
'd9312da562da182b02322fd8acb536f37eb9d29fba7c49dc172555274d657368546f6b656e'
);
Fetch Asset Addresses
Fetch a list of a addresses containing a specific asset
where it is the concatenation of policy ID and asset.
await provider.fetchAssetAddresses('d9312da562da182b02322fd8acb536f37eb9d29fba7c49dc172555274d657368546f6b656e')
Fetch Asset Metadata
Fetch the asset metadata by providing asset's unit
, which is the concatenation of policy ID and asset name in hex.
await provider.fetchAssetMetadata('d9312da562da182b02322fd8acb536f37eb9d29fba7c49dc172555274d657368546f6b656e')
Fetch Block Info
Fetch block infomation. You can get the hash from fetchTxInfo()
.
await provider.fetchBlockInfo('79f60880b097ec7dabb81f75f0b52fedf5e922d4f779a11c0c432dcf22c56089')
Fetch Collection Assets
Fetch a list of assets belonging to a collection by providing its Policy ID.
await provider.fetchCollectionAssets('d9312da562da182b02322fd8acb536f37eb9d29fba7c49dc17255527')
The API will return a list of assets
and a cursor next
. If the cursor is not null, you can use it to fetch the next page of results. Here is an example of the response.
{
"assets": [
{
"unit": "d9312da562da182b02322fd8acb536f37eb9d29fba7c49dc17255527",
"quantity": "1"
},
],
"next": 2
}
The fetchCollectionAssets
function also accepts an optional cursor
parameter to fetch the next page of results. The default value is 1
.
await fetchCollectionAssets(
policyId: string,
cursor = 1
)
Fetch Handle Address
ADA Handle allows users to use a human-readable "Handle" to associate an address.
Each Handle is a unique NFT, minted and issued on the Cardano blockchain. These NFTs act as unique identifiers for the UTXO that they reside in.
We can resolve the handle's address with fetchHandleAddress
.
// Handle: `meshsdk`
await provider.fetchHandleAddress('meshsdk')
Fetch Handle
ADA Handle allows users to use a human-readable "Handle" to associate an address.
Each Handle is a unique NFT, minted and issued on the Cardano blockchain. These NFTs act as unique identifiers for the UTXO that they reside in.
ADA Handle also released a CIP68 handle and this function will fetch the metadata of the handle.
// Handle: `meshsdk`
await provider.fetchHandle('meshsdk')
Fetch Protocol Parameters
Fetch the latest protocol parameters.
await provider.fetchProtocolParameters()
Optionally, you can provide an epoch number to fetch the protocol parameters of that epoch.
Fetch Transaction Info
Fetch transaction infomation. Only confirmed transaction can be retrieved.
await provider.fetchTxInfo('f4ec9833a3bf95403d395f699bc564938f3419537e7fb5084425d3838a4b6159')
Fetch UTxOs
Get UTxOs for a given hash.
// Hash: `dfd2a2616e6154a092807b1ceebb9ddcadc0f22cf5c8e0e6b0757815083ccb70`
await provider.fetchUTxOs('dfd2a2616e6154a092807b1ceebb9ddcadc0f22cf5c8e0e6b0757815083ccb70')
Optionally, you can specify the index of the index output.
await provider.fetchUTxOs('hash_here', 0)
Fetch Proposal Info
Get information for a given governance proposal, identified by the txHash and proposal index
await provider.fetchGovernanceProposal('372d688faa77e146798b581b322c0f2981a9023764736ade5d12e0e4e796af8c', 0)
Evaluate Transaction
evaluateTx()
accepts an unsigned transaction (unsignedTx
) and it evaluates the resources required to execute the transaction. Note that, this is only valid for transaction interacting with redeemer (smart contract). By knowing the budget required, you can use this to adjust the redeemer's budget so you don't spend more than you need to execute transactions for this smart contract.
const unsignedTx = await tx.build();
const evaluateTx = await provider.evaluateTx(unsignedTx);
Example responses from unlocking assets from the always succeed smart contract.
[
{
"index": 0,
"tag": "SPEND",
"budget": {
"mem": 1700,
"steps": 368100
}
}
]
With the mem
and steps
, you can refine the budget for the redeemer. For example:
const redeemer = {
data: { alternative: 0, fields: [...] },
budget: {
mem: 1700,
steps: 368100,
},
};
Submit Transaction
Submit a serialized transaction to the network.
await provider.submitTx(signedTx);
On Transaction Confirmed
Allow you to listen to a transaction confirmation. Upon confirmation, the callback will be called.
const tx = new Transaction({ initiator: wallet });
tx.sendLovelace('addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr', '5000000');
const unsignedTx = await tx.build();
const signedTx = await wallet.signTx(unsignedTx);
const txHash = await wallet.submitTx(signedTx);
provider.onTxConfirmed(txHash, () => {
// Transaction confirmed
});
Admin Get Devnet Info
Get information about the devnet.
await provider.getDevnetInfo()
Example response:
{
"nodePort": 0,
"submitApiPort": 0,
"socketPath": "string",
"protocolMagic": 0,
"slotLength": 0,
"blockTime": 0,
"epochLength": 0,
"p2pEnabled": true,
"startTime": 0,
"masterNode": true,
"adminNodeUrl": "string",
"era": "Byron",
"genesisProfile": "zero_fee",
"ogmiosPort": 0,
"kupoPort": 0,
"yaciStorePort": 0,
"socatPort": 0,
"prometheusPort": 0,
"blockProducer": true
}
Admin Get Genesis Info By Era
You can topup ADA for any address. To topup ADA in your wallet, run the following command from devnet:
await provider.getGenesisByEra(<era>)
Example response:
{
"activeSlotsCoeff": 1,
"epochLength": 500,
"genDelegs": {
"337bc5ef0f1abf205624555c13a37258c42b46b1259a6b1a6d82574e": {
"delegate": "41fd6bb31f34469320aa47cf6ccc3918e58a06d60ea1f2361efe2458",
"vrf": "7053e3ecd2b19db13e5338aa75fb518fc08b6c218f56ad65760d3eb074be95d4"
}
},
"initialFunds": {
"60ba957a0fff6816021b2afa7900beea68fd10f2d78fb5b64de0d2379c": 3000000000000000,
"007290ea8fa9433c1045a4c8473959ad608e6c03a58c7de33bdbd3ce6f295b987135610616f3c74e11c94d77b6ced5ccc93a7d719cfb135062": 300000000000,
"605276322ac7882434173dcc6441905f6737689bd309b68ad8b3614fd8": 3000000000000000,
"60a0f1aa7dca95017c11e7e373aebcf0c4568cf47ec12b94f8eb5bba8b": 3000000000000000,
"005867c3b8e27840f556ac268b781578b14c5661fc63ee720dbeab663f9d4dcd7e454d2434164f4efb8edeb358d86a1dad9ec6224cfcbce3e6": 1000000000
},
"maxKESEvolutions": 60,
"maxLovelaceSupply": 45000000000000000,
"networkId": "Testnet",
"networkMagic": 42,
"protocolParams": {
"a0": 0,
"decentralisationParam": 0,
"eMax": 18,
"extraEntropy": {
"tag": "NeutralNonce"
},
"keyDeposit": 2000000,
"maxBlockBodySize": 65536,
"maxBlockHeaderSize": 1100,
"maxTxSize": 16384,
"minFeeA": 0,
"minFeeB": 0,
"minPoolCost": 340000000,
"minUTxOValue": 1000000,
"nOpt": 100,
"poolDeposit": 500000000,
"protocolVersion": {
"major": 8,
"minor": 0
},
"rho": 0.003,
"tau": 0.2
},
"securityParam": 300,
"slotLength": 1,
"slotsPerKESPeriod": 129600,
"staking": {
"pools": {
"7301761068762f5900bde9eb7c1c15b09840285130f5b0f53606cc57": {
"cost": 340000000,
"margin": 0,
"metadata": null,
"owners": [],
"pledge": 0,
"publicKey": "7301761068762f5900bde9eb7c1c15b09840285130f5b0f53606cc57",
"relays": [],
"rewardAccount": {
"credential": {
"keyHash": "11a14edf73b08a0a27cb98b2c57eb37c780df18fcfcf6785ed5df84a"
},
"network": "Testnet"
},
"vrf": "c2b62ffa92ad18ffc117ea3abeb161a68885000a466f9c71db5e4731d6630061"
}
},
"stake": {
"9d4dcd7e454d2434164f4efb8edeb358d86a1dad9ec6224cfcbce3e6": "7301761068762f5900bde9eb7c1c15b09840285130f5b0f53606cc57"
}
},
"systemStart": "2024-10-30T05:11:07.442512Z",
"updateQuorum": 1
}
Admin Address Topup
You can topup ADA for any address. To topup ADA in your wallet, run the following command from devnet:
await provider.addressTopup(<address>, <amount>)
Topup Address
Admin function to topup address with ADA
Address
addr_test1qpvx....9uu0nq93swx9
Amount
20000000
await provider.addressTopup('addr_test1qpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0uafhxhu32dys6pvn6wlw8dav6cmp4pmtv7cc3yel9uu0nq93swx9', '20000000');