Mesh Integration
Mesh is similar to Lucid as it is also based on JavaScript and is web friendly. Mesh is developed independently by its developer community. It stands out by providing higher-level abstractions for common use cases such as transaction asset bundles, minting/burning NFTs, staking and more. Its focus is on simplicity and ease of use with React frontends.
Maestro Data Provider
const MaestroProvider = new MaestroProvider({
network: 'Preprod',
apiKey: '<Your-API-Key>',
turboSubmit: false
});
Provider and JSON keys definition:
network
: Define your network type: "Mainnet", "Preprod", "Preview".apiKey
: Maestro apiKey. Get a Free key here.turboSubmit
: Turn on Turbo Transaction submission, learn more here.
- The
MaestroProvider()
constructor is interchangeable with previous Mesh providers. Try the difference in performance! - Try the interactive demo at https://meshjs.dev/providers/maestro with your own arguments.
Available Mesh functionalities
The Maestro provider in Mesh can act as a Fetcher, Submitter and Listener, supporting all Mesh functionalities:
- Fetch Account Info
- Fetch Address Utxos
- Fetch Asset Addresses
- Fetch Asset Metadata
- Fetch Block Info
- Fetch Collection Assets
- Fetch Handle Address
- Fetch Protocol Parameters
- Fetch Transaction Info
- Submit Tx
- On Transaction Confirmed
Mesh code examples
Fetch Address Utxos
Fetch UTxOs at the provided address
. Optionally, you can filter UTxOs containing a particular asset by providing asset
(where it is the concatenation of policy ID and asset). See the full interactive demo here.
await MaestroProvider.fetchAddressUTxOs(
'addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr',
'd9312da562da182b02322fd8acb536f37eb9d29fba7c49dc172555274d657368546f6b656e',
)
Mesh result
[
{
"input": {
"outputIndex": 0,
"txHash": "e92ab314324d6eb2aa23f4cc7e1bd6be23c54867de3f10c55052b274904b4cf4"
},
"output": {
"address": "addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr",
"amount": [
{
"unit": "lovelace",
"quantity": "1159390"
},
{
"unit": "d9312da562da182b02322fd8acb536f37eb9d29fba7c49dc172555274d657368546f6b656e",
"quantity": "1"
}
]
}
}
...
]
On Transaction Confirmed
Allow to listen to a transaction confirmation. Upon confirmation, the callback will be called. See the full live demo here.
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);
MaestroProvider.onTxConfirmed(txHash, () => {
console.log('Transaction confirmed');
});
Getting Started
Run a local version of the https://meshjs.dev/ demo! Experiment with the Maestro provider in MeshJS in minutes.
// Clone the MeshJS repository
git clone https://github.com/MeshJS/mesh
// On the first time you may need to run
yarn install
yarn bootstrap
yarn run build:react
// Set your apiKeys in environment variables
MAESTRO_API_KEY_MAINNET=<Your-API-Key>
MAESTRO_API_KEY_PREPRPOD=<Your-API-Key>
MAESTRO_API_KEY_PREVIEW=<Your-API-Key>
// test with echo if necessary, e.g. echo $MAESTRO_API_KEY_PREPRPOD
// on one terminal, start the Mesh core
yarn run start:module
// on a separate terminal, start the Demo app
yarn run start:demo
Starter Templates for diverse Use Cases
At https://meshjs.dev/starter-templates there are several TypeScript and Javascript repositories enabling:
- A starter project with wallet integration
- Mint/Sell tokens with multi-sig transactions
- Stake pool delegation to a chosen pool
- Sign In with Wallet
- An ecommerce store
- An NFT marketplace
- plu-ts smart contract deployment