Giter Site home page Giter Site logo

meshjs / mesh Goto Github PK

View Code? Open in Web Editor NEW
191.0 14.0 53.0 37.87 MB

An open-source library to advance Web3 development on Cardano

Home Page: https://meshjs.dev

License: Apache License 2.0

TypeScript 94.65% JavaScript 0.84% CSS 0.21% MDX 4.24% Shell 0.05%
cardano web3 sdk typescript

mesh's Introduction

Mesh Logo


Mesh SDK

Licence Build Package

Twitter/X NPM


Mesh is an open-source library designed to make building dApps accessible. Whether you're a beginner developer, startup, web3 market leader, or a large enterprise, Mesh makes web3 development easy with reliable, scalable, and well-engineered APIs & developer tools.

Explore the features on Mesh Playground.

What's inside?

This Turborepo includes the following packages/apps:

Packages

Apps

Getting Started

Usage

To use Mesh in your project, run the following command to install the core package:

npm install @meshsdk/core

Install

To install all dependencies, run the following command:

npm install

Build

To build all apps and packages, run the following command:

npm run build

Develop

To develop all apps and packages, run the following command:

npm run dev

Alt

mesh's People

Contributors

abdelkrimdev avatar alainmgz avatar brian-atriumlab avatar esot321c avatar fabianbormann avatar hinsonsidan avatar invertalwaysinvert avatar jinglescode avatar jmagan avatar leonlai257 avatar pablosymc avatar pedrolucasnet avatar ryun1 avatar saphst4r avatar sidanpillow avatar sourabhxyz avatar twwu123 avatar zagita21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mesh's Issues

BrowserWallet: can't build TX unless I send assets to myself

My holders are all experiencing the same issue:
They must send 3 NFTs and 5 ADA, to get 1 Key.
Problem is, every time they try to build a TX, this error occurs:
[Transaction] An error occurred during build: Not enough ADA leftover to include non-ADA assets in a change address.

They then have to send their assets + ADA to themselves, and only then can they build a TX.
I noticed these wallets can still do things like bulk-list on jpg.store, even if they are supposedly "clogged".

Could this be a Mesh issue?
Here's the code for building the TX (95% of 1st attempts end up with the above error)

const tx = new Transaction({ initiator: wallet })
  .sendLovelace({ address: BURN_ADDRESS }, String(5 * ONE_MILLION))
  .sendAssets({ address: BURN_ADDRESS }, [
    {
      unit: selectedMale,
      quantity: '1',
    },
    {
      unit: selectedFemale,
      quantity: '1',
    },
    {
      unit: selectedBike,
      quantity: '1',
    },
  ])

const unsignedTx = await tx.build()
const signedTx = await wallet.signTx(unsignedTx)
const txHash = await wallet.submitTx(signedTx)

Could you provide a license

Hi there,

your project is still very cool! It would be great if you could provide a LICENSE file to root of the project and also add that license to the license field the package.json (and maybe - if you want - remove the "private: true").

Thanks,
Fabian

BREAKING CHANGE: Since webpack 5 WebAssembly is not enabled by default and flagged as experimental feature.

Hi.

I am following the Start a Web3 app on Next.js from link.

After See it in action -> 1. Add MeshProvider my application stops with the following error:

./node_modules/@emurgo/cardano-message-signing-browser/cardano_message_signing_bg.wasm
Module parse failed: Unexpected character '' (1:0)
The module seem to be a WebAssembly module, but module is not flagged as WebAssembly module for webpack.
BREAKING CHANGE: Since webpack 5 WebAssembly is not enabled by default and flagged as experimental feature.
You need to enable one of the WebAssembly experiments via 'experiments.asyncWebAssembly: true' (based on async modules) or 'experiments.syncWebAssembly: true' (like webpack 4, deprecated).
For files that transpile to WebAssembly, make sure to set the module type in the 'module.rules' section of the config (e. g. 'type: "webassembly/async"').
(Source code omitted for this binary file)

I would hope not to have to set the experimental flag to use Mesh.

Is the guide outdated or have I done something wrong?

BrowserWallet: building TX does not include UTXOs ADA in added Lovelace value

I am building a TX, that should include 3 assets, and 5 ADA in total.

Expected behavior:
TX should include 3 assets, 5 ADA total, + TX fee.

Real behavior:
TX includes 3 assets, 6.xx ADA total, + TX fee

const tx = new Transaction({ initiator: wallet })
  .sendLovelace({ address: BURN_ADDRESS }, String(5 * ONE_MILLION))
  .sendAssets({ address: BURN_ADDRESS }, [
    {
      unit: selectedMale,
      quantity: '1',
    },
    {
      unit: selectedFemale,
      quantity: '1',
    },
    {
      unit: selectedBike,
      quantity: '1',
    },
  ])

const unsignedTx = await tx.build()
const signedTx = await wallet.signTx(unsignedTx)
const txHash = await wallet.submitTx(signedTx)

Stakepool Web Page Template - Connect Wallet Button Stuck in "Checking.." if wallet is set on a different network

Hello Mesh Team,

thanks for you great work! I set up the page for my stakepool with Mesh, then I deployed on IPFS with Fleek.
A collegue reported me that wallet connect button get stuck in "Checking.." if wallet is set on a different network.

I'm conscious that if one set up a page for a stakepool with Mesh is not for testnets stakepools delegation, nevertheless
would be great add a message inside the button (something like "wrong network") if a user try to delegate having the wallet set on
a non mainnet network.

Many thanks in advance,
best regards,
Manuel

Sending exact lovelace values with assets

Could there be an option to include any minimum ADA required as part of the transaction amount to send?

For instance, in the example below, the final lovelace value that will be built is around 4.3 ADA due to the minimum amount required to send assets.

There should be an option to take out the minimum required ADA from the lovelace amount specified so the amount to send after building the transaction will still be the specified ADA - 3ADA in this case.

    const tx = new Transaction({ initiator: wallet })
        .sendLovelace(
          'someAddress',
          '3000000'
        )
        .sendAssets(
          'someAddress',
          [
            {
              unit: 'someAsset',
              quantity: '1',
            },
          ]
        );

Typhon Wallet not always detected

I have the latest version of Mesh.
It detects all my installed wallets with no problem, but Typhon isn't always detected.

I am not sure when it is detected, and when it isn't - it's random.

datum.inline = true, cannot use redeemValue

code example

import {BrowserWallet, KoiosProvider, resolveDataHash, resolvePlutusScriptAddress} from '@meshsdk/core';
import type { PlutusScript } from '@meshsdk/core';
import { Transaction } from '@meshsdk/core';
const script: PlutusScript = {
  code: '4e4d01000033222220051200120011',
  version: 'V2',
};
const scriptAddress = resolvePlutusScriptAddress(script, 0);

const datum = 'lock22'
const asset = "76e5219bf4ab56335985f8c85ccfb7a54716a6eeb94c13e80ab1558553776170546f6b656e"
export default function D3(){
  const onLock = async () => {
    const wallet = await BrowserWallet.enable('nami');
    const tx = new Transaction({ initiator: wallet })
      .sendAssets(
        {
          address: scriptAddress,
          datum: {
            value: datum,
            inline: true
          },
        },
        [
          {
            unit: asset,
            quantity: "2",
          },
        ],
      );
    const unsignedTx = await tx.build();
    const signedTx = await wallet.signTx(unsignedTx);
    console.log('signedTx', signedTx)
    const txHash = await wallet.submitTx(signedTx);
  }

  const onUnLock = async () => {
    async function _getAssetUtxo({ scriptAddress, asset, datum }) {
      const koios = new KoiosProvider('preprod');

      const utxos = await koios.fetchAddressUTxOs(
        scriptAddress,
        asset
      );
      console.log('utxos', utxos)

      const dataHash = resolveDataHash(datum);
      let utxo = utxos.find((utxo: any) => {
        return utxo.output.dataHash == dataHash;
      });

      return utxo;
    }

    const assetUtxo = await _getAssetUtxo({
      scriptAddress: scriptAddress,
      asset: asset,
      datum: datum,
    });
    const wallet = await BrowserWallet.enable('nami');
    const address = await wallet.getChangeAddress();

    console.log('assetUtxo', assetUtxo)
    const tx = new Transaction({ initiator: wallet })
      .redeemValue({
        value: assetUtxo,
        script,
        datum: datum,
      })
      .sendValue(address, assetUtxo) // address is recipient address
      .setRequiredSigners([address]);

    const unsignedTx = await tx.build();
    const signedTx = await wallet.signTx(unsignedTx, true);
    console.log('signedTx', signedTx)
    const txHash = await wallet.submitTx(signedTx);
    console.log('txHash', txHash)

  }
  return <div>
    <button onClick={onLock}>Lock Asset</button>
    <button onClick={onUnLock}>Unlock Asset</button>
  </div>
}

when datum.inline = false,the onLock tx is success,onUnLock tx is success
when datum.inline = true,the onLock tx is success,onUnLock tx is error

error

{
    "code": 2,
    "info": "Wallet could not send the tx.",
    "message": "\"transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (FromAlonzoUtxowFail (NonOutputSupplimentaryDatums (fromList [SafeHash \\\"5314744672c0f5b84d1a69d1dbdedcf0471b8aaa3fdeaa6175af91de5e317ecd\\\"]) (fromList [])))])\""
}

An error occurred during build: Insufficient input in transaction. shortage: {policy id: "22f20d5382cec46166b566821f16f79cb03ee1520c71e5f83a4b3f20", asset name: "54657374746f6b656e" coins in inputs: 0, coins in outputs: 1

core.js?3bda:2444 Uncaught (in promise) Error: [Transaction] An error occurred during build: Insufficient input in transaction. shortage: {policy id: "22f20d5382cec46166b566821f16f79cb03ee1520c71e5f83a4b3f20", asset name: "54657374746f6b656e" coins in inputs: 0, coins in outputs: 1
}.
at L.build (core.js?3bda:2444:1)
at async lockFunds (index.tsx?07ff:36:26)

What did I miss to get this error?

Transaction address cut short

Problem

Whenever I run ...getPaymentAddress() it returns only 58 characters of the payment address. For example, one of my wallet addresses it returns is: addr1vyjpy2h4s9zk975vcvfe6g7v5qmrfnc4f7s6zmrg022wf3s3qfda4 where the actual is supposed to be addr1qyjpy2h4s9zk975vcvfe6g7v5qmrfnc4f7s6zmrg022wf35kssj30r270nm07q3sz7gsquygkhsqxdfkxz6wcuwvc2fsvj99ks

Sending minted asset from AppWallet... but make user pay fee (via Multi Sig)

Hi there, essentially what i'm looking to do... is send an already minted asset from the "AppWallet" to the user on the frontend via a multi sig transaction. The reason I'd like to do it via multi sig is because i'd like to have the user pay the transaction fee. Can someone assist me with guidance on how I could accomplish this?

I'm looking for a solution similar to https://github.com/MeshJS/minting-next-js-template/blob/main/pages/api/create-mining-transaction.js however instead of minting an asset to the user, i'd like to send an already minted asset from the "AppWallet" 😃

Issue with `enoughValueHasBeenSelected` function

I have a UTXO that looks like this:

image

The outputSet map I passed to the largestFirstMultiAsset looks like this:

const lovelaceMap = new Map();
lovelaceMap.set("lovelace", 4000000.toString())

When I run the largestFirstMultiAsset function it's returning only this 1 UTXO shown above... because the enoughValueHasBeenSelected function is saying that there is enough value in it

It's adding the lovelace unit quantity and the quantity of the asset there which has like 3999999999 etc (as shown above in the image). This is not correct though.

I DO NOT have enough lovelace quantity (4000000) in this 1 UTXO (shown above)

Shouldn't this code block here in the enoughValueHasBeenSelected function only be reducing amounts that match the asset.unit variable - which in this case is lovelace?

image

Doing something like this seems to return the correct amount of UTXO's (2 instead of 1) from the largestFirstMultiAsset function

image

npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree

  1. What causese this error or npm dependecy error?
  2. What do you do to solve it?
  3. Why are you getting this error?

wims@wimspc:~/mesh/packages/demo$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: @meshsdk/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"18.2.0" from @meshsdk/[email protected]
npm ERR! packages/demo
npm ERR! @meshsdk/[email protected]
npm ERR! node_modules/@meshsdk/playground
npm ERR! workspace packages/demo from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^15.0.0 || ^16.0.0 || ^17.0.0" from [email protected]
npm ERR! node_modules/react-highlight
npm ERR! react-highlight@"^0.14.0" from @meshsdk/[email protected]
npm ERR! packages/demo
npm ERR! @meshsdk/[email protected]
npm ERR! node_modules/@meshsdk/playground
npm ERR! workspace packages/demo from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /home/wims/.npm/_logs/2023-03-27T01_07_07_726Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR! /home/wims/.npm/_logs/2023-03-27T01_07_07_726Z-debug-0.log

Answers:

  1. This is caused by using a reactjs version lower than the reactjs used in the project you have cloned and have executed the command npm install. Actually it is a node version problem. Your node version is lower than that of the latest project being cloned.
  2. There are many ways to solve this: a) upgrade your nodejs if possible. b) if not possible then run npm install --force and know that you might face dependency issues with the project at some point in time unless you are lucky
  3. The reality is that we will never be on the same versions in our different projects and as such one has to do a thorough research of the needs of what you are doing well in advance

Typhon Wallet not supported yet

Typhon Wallet is a CIP-30 wallet developed by Cardanoscan.io
I use this wallet, and it's not detected by Mesh yet, please add support for it

Add sample to lock the policy when minting assets

The current samples shows the minting of assets with no policy locking.

How would one achieve policy locking?

Digging deeper, I discovered that I can add the expiry to the forgeScript . In order to do this, the csl library should be exposed by the module, but it is not, I guess.

Any advice is appreciated!

How to sign a minting transaction with a policy locking script

From what I understand I need to sign the transaction with both the policy skey and the wallet skey however when I do this I get the following cute exception "OUR_PRINCESS_IS_IN_ANOTHER_CASTLE", but doesn't tell me much;


    const nativeScript = {
        type: 'all',
        scripts: [
            {
                type: 'before',
                slot: '94041911',
            },
            {
                type: 'sig',
                keyHash: '<REDACTED>',
            },
        ],
    };

    const forgingScript = ForgeScript.fromNativeScript(nativeScript);
    console.log(forgingScript);

    let tx = new Transaction({ initiator: policyWallet });

Build asset and transaction

        const unsignedTx = await tx.build();
        const signedTx1 = await policyWallet.signTx(unsignedTx, false);
        const signedTx2 = await wallet.signTx(signedTx1, false);
        const txHash = await policyWallet.submitTx(signedTx2);
Error: [AppWallet] An error occurred during signTx: Error: An error occurred during signTx: Error: Missing key witness for: OUR_PRINCESS_IS_IN_ANOTHER_CASTLE..
    at Ls.signTx (/Users/josh.bondy/Documents/Projects/jetplane/jetplane-nft/node_modules/@martifylabs/mesh/dist/mesh.cjs:1:65237)

Cardano Serialization Lib error on initial setup

Hello! Thanks Mesh team for all your work on the SDK. I attempted to follow your documentation from https://meshjs.dev/guides/nextjs exactly to set up a Next.js application, but ran into trouble trying to wrap a component in ....The stack trace is pointing to cardano-serialization-lib but I have no idea how to fix! Any help appreciated, would really love to give your SDK a try. I'm running Next version 13.4.0 and have configured Next.config.js exactly as in your documentation.

=======================================
warn - ./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js
./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib.js
./node_modules/@meshsdk/core/dist/core.js
./node_modules/@meshsdk/react/dist/react.js
./app/page.tsx

./node_modules/@emurgo/cardano-serialization-lib-nodejs/cardano_serialization_lib.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/@emurgo/cardano-serialization-lib-nodejs/cardano_serialization_lib.js
./node_modules/@meshsdk/core/dist/core.js
./node_modules/@meshsdk/react/dist/react.js
./app/page.tsx
error - Error: ENOENT: no such file or directory, open 'C:\Users\katie\Documents\WebDevelopment\nextpractice2.next\server\app\cardano_serialization_lib_bg.wasm'
at Object.openSync (node:fs:600:3)
at Object.readFileSync (node:fs:468:35)
at webpack_require (C:\Users\katie\Documents\WebDevelopment\nextpractice2.next\server\webpack-runtime.js:33:42)
at webpack_require (C:\Users\katie\Documents\WebDevelopment\nextpractice2.next\server\webpack-runtime.js:33:42)
at webpack_require (C:\Users\katie\Documents\WebDevelopment\nextpractice2.next\server\webpack-runtime.js:33:42)
at eval (./app/page.tsx:11:72)
at (sc_client)/./app/page.tsx (C:\Users\katie\Documents\WebDevelopment\nextpractice2.next\server\app\page.js:1228:1)
at webpack_require (C:\Users\katie\Documents\WebDevelopment\nextpractice2.next\server\webpack-runtime.js:33:42)

Unlock utxo with sc failing

Full code

  const blockfrostProvider = new BlockfrostProvider(
    '',
  );
  const utxos = await blockfrostProvider.fetchAddressUtxos(
    scriptAddress,
    asset
  );

  let utxo = utxos.find((utxo) => {
    return utxo.output.dataHash == dataHash;
  });
  return utxo;
}

export const purchaseToken = async (asset) => {
  const Wallet = await BrowserWallet.enable('nami');
  const assetUtxo = await getAssetUtxo({
    scriptAddress: marketAddress,
    asset: asset.details.asset,
    dataHash: asset.status.datumHash,
  });
  console.log(assetUtxo, 'asset');

  if (assetUtxo) {
    // get wallet change address
    const address = await Wallet.getChangeAddress();
    const tx = new Transaction({ initiator: Wallet })
      .redeemValue(Contracts.v1.cborHex, assetUtxo, { cs, ra, rp, sa, tn, price })
      .sendValue(address, assetUtxo)
      .sendLovelace(realOwner, String(asset.status.datum.price))
      .setRequiredSigners([address]);
    const unsignedTx = await tx.build();
    const signedTx = await Wallet.signTx(unsignedTx, true); // partial sign is true
    const txHash = await Wallet.submitTx(signedTx);
    console.log(txHash, 'submitTx');
    return txHash;
  }
};

Error

{
    "code": 2,
    "info": "Wallet could not send the tx.",
    "message": "\"transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (FromAlonzoUtxowFail (MissingRequiredDatums (fromList [SafeHash \\\"\\\"]) (fromList [SafeHash \\\"\\\"]))),UtxowFailure (FromAlonzoUtxowFail (NonOutputSupplimentaryDatums (fromList [SafeHash \\\"\\\"]) (fromList [])))])\""
}

https://drive.google.com/file/d/1ivHB4sJqb3v8nzSvdix9zfcD3PAwYHJu/view?usp=share_link
https://drive.google.com/file/d/1-CnsKv-ltCeXOEsPlHa5O-OodAA5ct_y/view?usp=share_link

mintAsset requires mint Metadata

The examples only show minting with Metadata attached and trying to omit it when building a mintAsset transaction fails. Metadata should however not be a requirement for minting assets.

Emurgo: TexDecoder is not a constructor

Screenshot 2022-11-29 205116
textdecoder is not a constructor

I am attempting to implement @martifylabs/mesh on a Vue project. The line...

import { BrowserWallet } from '@martifylabs/mesh';

immediately starts causing issues. This one in particular, it seems like mesh.js is using TextDecoder from the cardano-serialization-library-nodejs.js in an unexpected way.

Should I be using a different version of mesh (see screenshot)? What version of Node do you recommend?

Transaction build fail: UTxO Balance Insufficient

The issue

Whenever I build a minting transaction, the build fails with a UTxO Balance Insufficient error. Irrespective of the wallet size (in Ada) or the number of UTXOs in the wallet.

Code to reproduce

const blockchainProvider = new KoiosProvider("api");

    // Load the wallet
    const wallet = new AppWallet({
      networkId: 1,
      fetcher: blockchainProvider,
      submitter: blockchainProvider,
      key: {
        type: "mnemonic",
        words: Phrase,
      },
    });

    // Get the policy ID
    const walletAddress = wallet.getPaymentAddress();
    const address = usedAddress.to_bech32();
    const forgingScript = ForgeScript.withOneSignature(address);

    // Build the transaction object
    const tx = new Transaction({ initiator: wallet });

    // build transaction
    const assetToMintMetadata: AssetMetadata = {
      ...metadata content ...
    };

    const asset1: Mint = {
      assetName: "TestingNFT",
      assetQuantity: "1",
      metadata: assetToMintMetadata,
      label: "721",
      recipient: {
        address:
          "addr1q9...9c7g3",
      },
    };

      tx.mintAsset(
        forgingScript,
        asset1,
      );

    const unsignedTx = await tx.build();

Stacktrace

yarn run v1.22.19
$ tsc && node ./dist/main.js
error Error: [Transaction] An error occurred during build: UTxO Balance Insufficient.
    at Object.build (file:///somedir/node_modules/@martifylabs/mesh/dist/index.js:1330:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async main (file:///somedir/dist/main.js:47:28)
    at async file:///somedir/dist/main.js:60:1
Done in 2.77s.```

Building a transaction that will require both payment and stake signature?

It is possible to build a transaction with mesh that will require both payment and staking signature? A simple transaction such as sending ADA from one wallet to another wallet will do.

My goal is to prevent the Franken address attack. In Cardano, we usually manage whitelist with stake address but it's prone to Franken address attack. That's why I want to build a transaction where the user's staking key signature will also be needed.

Is it supported in mesh SDK?

New wallet: Lace

More of a request, rather than an issue.
Lace wallet is released in Mainnet, can we please get it on the list of supported browser wallets?

blockfrostProvider.fetchAssetAddresses is not a function

The title says it all. I tried using the blockfrost provider but it seems the fetchAssetAddresses is not available.

Relevant piece of code is taken from one of your examples but I'll paste it here just for the reference:

    const blockfrostProvider = new BlockfrostProvider('*************');
    let x = await blockfrostProvider.fetchAssetAddresses(
      'd9312da562da182b02322fd8acb536f37eb9d29fba7c49dc172555274d657368546f6b656e',
    )

    console.log(x);

Am I doing something wrong here? (sorry not a frontend guy)

Reference documentation

I had a look at mesh today and I love the guides. They are simple to understand workable examples.

Deviating from there is however close to impossible right now, because there is no way to inspect types apart from digging into the source code (manually!). Please set up some kind of reference, be it something auto-generated, just so that users can look up each type and definition without having to dig the source code for it.

Typhon wallet is not working

I'm trying to connect typhon wallet its not work for me .
Code I'm running :
import { useWallet, useLovelace, CardanoWallet } from "@meshsdk/react"; const { wallet, connected, name, connecting, connect, disconnect, error } = useWallet(); connect("typhoncip30");
Note :
I'm using latest version of @meshsdk/react

Error :
image

resolveSlotNo returns incorrect POSIX TIme

Here is an example of how I am using it


const addMinutes = (minutes) => {
  return new Date(Date.now() + minutes * 60000).getTime();
};

const slot = resolveSlotNo('preprod', addMinutes(10));

slot = 27345986

When I use this deadline in my validator I get the following error

{"invalidBefore":27345986,"invalidHereafter":null},"currentSlot":25198745}

This seems to be way off, I believe its not the addMinutes functions because I have tried it and it returns a valid timestamp

Multiple Signature with multiple App Wallets

Hello folks at MeshJS

Recently I've been trying out the multi-sig tutorial and wanting to multi-sig with APP wallets only

const unsignedTx = await tx.build();
const signed1 = await appWallet1.signTx(unsignedTx, true);
const signed2 = await appWallet2.signTx(signed1, true);

Yet this seems to result in a very tiny change on the CBOR string only, (unlike, for example, if I follow the guide and do one App wallet sign followed by one Browser wallet sign; in this case the CBOR is clearly extended with a signature-like string as according to cbor.me)

Want to check if this is part of current limitation of the app wallet? or is this part of the multi-sig limitation?

Thank you in advance
Best Regards
EL

Can't get AppWallet instance using private key

Warning: I generated a private key specifically for this post, don't worry

If you use a private key: "xprv12zhcvwkyatecqyfcs3lg8pjsx3zja0ds3783tlcajd8cja24raqqmy6stmp3tyxcucthw2nx78kl5d5x5t9p9g5vdthqe58ymd093z45a4l5m4e4rmvxyg8npens3zt2l6j03xyqzkyvxp0q0nyfm8r0yl0hfm2r7nln6sfaml28zkfdzlg28knkgvzr3w8f977ca5m3ulku560tw3y"
in your sandbox:
https://meshjs.dev/apis/appwallet
then you will get an error:
"Invalid secret key"

I get a similar error when I try to use the library in our application in the browser.
The private key is working, you can use it to sign transactions.

When I try to get an instance of AppWallet by mnemonics, I get an incorrect address, it is much shorter than the original one.

Maybe you have other ways to get a wallet instance that can be used to sign transactions later using the Transaction class of your library?

Conflicted dependencies

I am trying to update my dependencies as following:

@meshsdk/core   ^1.3.0  →  ^1.4.1
@meshsdk/react  ^1.1.3  →  ^1.1.4

But I get an error while installing:

'Log files:
/Users/ben/.npm/_logs/2023-02-07T15_48_26_551Z-debug-0.log

# npm resolution error report

While resolving: [email protected]
Found: @meshsdk/[email protected]
node_modules/@meshsdk/core
  @meshsdk/core@"^1.4.1" from the root project

Could not resolve dependency:
peer @meshsdk/core@"1.4.0" from @meshsdk/[email protected]
node_modules/@meshsdk/react
  @meshsdk/react@"^1.1.4" from the root project

Fix the upstream dependency conflict, or retry
this command with --force or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

Minting on Node.js guide

Hi,

Playing with the Minting on Node.js guide I stumble upon the following error with the first instruction:

#> npm init .
npm ERR! code EUNSUPPORTED
npm ERR! Unrecognized initializer: .
npm ERR! For more package binary executing power check out `npx`:
npm ERR! https://docs.npmjs.com/cli/commands/npx

Execution environment:

#> node --version
v19.8.1
#> npm --version
9.5.1
#> uname -a
Darwin MacBook-Pro 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:58 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6020 arm64

Royalty token issue -- mandatory metadata

Currently, there is no way to mint royalty tokens without the policy id attached.
I was able to generate a token with the 777 label, the issue is that it had the policy id and asset name attached in the metadata. Wondering if there's a way to get rid of this metadata.

TokenI mint using mesh:

{
   "policyId": {
      "": {
         "addr": [ "addr_test1djfkh8skjne8u8wknsafnekjaikjkkasfgj9w89nsakjf84nuknsf9",
            "msf4jj70v7n30289afjknr4389wjknfsa893jknfs893"
         ],
         "rate": "0.025"
      }
   }
}

What royalty token should be:

{
  "addr": [ "addr_test1djfkh8skjne8u8wknsafnekjaikjkkasfgj9w89nsakjf84nuknsf9",
    "msf4jj70v7n30289afjknr4389wjknfsa893jknfs893"
  ],
  "rate": "0.025"
}

After went through the repo, I found the issue is the metadata format being fixed by forgeAssetsIfNeeded(), forge()

private async forgeAssetsIfNeeded() {

Keep inline datum in outgoing UTxO

Desired behavior:
When building a smart contract transaction, a UTxO is spent from a Contract address, and a new UTxO is output to the same Contract address. The inline datum in the Output UTxO should be unchanged from input UTxO.

Current solution:
I can use a GraphQL query to get the datum.bytes or the datum.value in an on-chain UTxO. The UTxO type in Mesh has an output.plutusData field where I can add the datum.bytes in the Input UTxO.

When building the transaction, I can use sendValue to send a UTxO back to the contract, where the "output" inline datum is included as the Recipient.datum. However, this requires the datum to be reconstructed in my TypeScript code. I could write a helper function that takes the datum.value from my GraphQL query, reformatting it as a Mesh Data object, but this seems inconvenient when the datum is already serialized on-chain.

Question / desired solution:
Is there currently a way that I can simply add the datum.bytes from my original query as inline datum to an output UTxO?

Svelte

Hello

I'm interested in using MeshJs in a new project. However the project is based on Svelte, rather than React.

Do I just use the @meshsdk/core package? Does this have all the functionality, minus the presentation layer?

Thanks

"browser" field in package.json is not respected by Vite

In package.json the "browser" field is not respected, so Vite runs the client side app with nodejs and throws errors. This occurs when using SvelteKit. Webpack with NextJS seems to work just fine.

https://github.com/MeshJS/mesh/blob/main/packages/module/package.json#L44-L47

EDIT: I went down the GitHub rabbit hole and found this PR that's supposed to resolve this issue but has not been merged for over a year 🙁
https://github.com/vitejs/vite/pull/11219/files

App Wallet Not Grabbing All available UTxOs

I am setting up a function in my node.js backend to send ada pragmatically to my users.
This is how my wallet instance is setup. I am on mainnet btw.

const MNEMONIC = process.env.SEEDPHRASE;
const blockchainProvider = new Mesh.BlockfrostProvider(
  process.env.BLOCKFROST_PROJECT_ID
);

const wallet = new Mesh.AppWallet({
  networkId: 1,
  fetcher: blockchainProvider,
  submitter: blockchainProvider,
  key: {
    type: 'mnemonic',
    words: MNEMONIC.split(' '),
  },
});

There is ada in that address but when i try to getAll available UTxOs it returns a blank array. When i try to submit a simple transfer event returns an error saying there is not enought UTxOs to cover the transaction.

I am not sure if this has anything to do with it , but when i do

console.log(wallet)

the protocol params that it returns is wrong. It has an epoch of just 0, all the parameters are wrong, and when i try switching to a different network, the protocol params stayed the same.

Error: getUsedCollateral not implemented..

Using AppWallet to send transaction to unlock assets as in this example.

Then get this error:

Error: [Transaction] An error occurred during build: Error: getUsedCollateral not implemented..
    at Object.build (/root/meshapp/node_modules/@martifylabs/mesh/dist/mesh.cjs:1:51612)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Same as this topic in stackexchange. Just put it here for reference.

[BrowserWallet] An error occurred during signTx: {"code":-1,"info":"Inputs do not conform to this spec or are otherwise invalid."}.

Uncaught (in promise) Error: [BrowserWallet] An error occurred during signTx: {"code":-1,"info":"Inputs do not conform to this spec or are otherwise invalid."}.

Here is the code below:

const tx = new Transaction({ initiator: wallet })
.sendAssets(
{
address: scriptAddr,
datum: {
value: d,
},
},
[
{
unit: "144a5f65ed8d4d10570d28d2c6764f8c63261696da6d4baa0d35998f57494d53454255546573746e6574546f6b656e73",
quantity: "1",
},
],
);
const unsignedTx = await tx.build();
const signedTx = await wallet.signTx(unsignedTx);

ForgeScript.fromNativeScript with time locking policy id not working

Hi I am using "@meshsdk/core" for multisignature tx. But when i add my policy script in it i give me error.
ERROR:
zsh: bus error node index.js

Code:

let nativeScript = {
  type: "all",
  scripts: [
    { type: "before", slot: 114276811 },
    {
      type: "sig",
      keyHash: "WalletKeyHash",
    },
  ],
};

const forgingScript = ForgeScript.fromNativeScript(nativeScript);

Datum not shown in utxo

I send lovelace to an address with datum like:

  tx.sendLovelace(
    {
      address: 'addr_test1vq8ncnj4xszdpy2ew0fzh8mudkwywqyz4fv8fkqh3jn20lsfkxtvt',
      datum: {
        value: {
          alternative: 0,
          fields: [49]
        },
        inline: true
      },
    },
    '1111111'
  );

The datum shows in the utxo as expected.

But when there are multiple objects in the fields like fields: [49,42] or fields: [49,'ABC'] the transaction is sent but no datum in the utxo. Also, the inline: true doesn't seem to make any difference.

Scrolls / Kupo2 / Freeloaderz based providers

Hi guys, there are likely many ideas how to evolve this application moving forward. My idea was to actually help to decentralise apps on Cardano. How?

Wouldn't it be nice to select other providers than Blockfrost, Kois, effectively self hosted more decentralised ones?

We could have scrolls / kupo2 and FreeLoaderz based providers. This would require splitting providers into reading and writing ones.

Reading:

  1. We could write or use existing reducers on scrolls (https://github.com/txpipe/scrolls) to read the data from redis (other dbs planned in the future as well)
  2. Alternatively one could try to make it work with KUPO2 but I have never used it

Writing:

  1. Why submit via blockfrost or Koios, we could actually submit via distributed network of servers. If you explore: https://www.freeloaderz.io/ you can see there are many urls to submit transactions, e.g. in europe, america etc.

Tell me what you think, I could perhaps help with scrolls / redis integration.

At the end if this works out we could have dApps using completely decentralised data stores without relying on koios / blockfrost at all.

Burning of partial token

while trying to burn token if we try to burn less than total amount the error 'Not enough ADA leftover to include non-ADA assets in a change address' occurs

Transaction build fail: memory access out of bounds

I'm connected with a Nami wallet.
I'm trying to build a TX with tx.sendLovelace(), but keep getting an error.

Code exmaple:

const tx = new Transaction({ initiator: wallet })

tx.sendLovelace({ address: 'addr1...' }, '1000000')

Error:

RuntimeError: memory access out of bounds
    at dlmalloc::dlmalloc::Chunk::size::hbcf51483386243e4 (7cca33c9a6f7f492.wasm:0x1e7ae5)
    at __rdl_realloc (7cca33c9a6f7f492.wasm:0x9b3d1)
    at __rust_realloc (7cca33c9a6f7f492.wasm:0x1e6822)
    at __wbindgen_realloc (7cca33c9a6f7f492.wasm:0x1e3c95)
    at passStringToWasm0 (cardano_serialization_lib_bg.js?11d8:92:1)
    at Address.from_bech32 (cardano_serialization_lib_bg.js?11d8:815:1)
    at U (index.js?5eb3:57:650)
    at ct (index.js?5eb3:147:42)
    at P.sendLovelace (index.js?5eb3:1194:1)
    at eval (index.js?cc2d:151:12)
    at step (tslib.es6.js?a65a:102:1)
    at Object.eval [as next] (tslib.es6.js?a65a:83:46)
    at asyncGeneratorStep (_async_to_generator.mjs?8538:3:1)
    at _next (_async_to_generator.mjs?8538:25:1)

Error: Can't call useWallet outside of the WalletProvider context

I am trying to use the useWallet hook similar to what is shown in the examples.
I am not aware how to provide a WalletProvider context - that type is not even defined using the dependencies:

@meshsdk/core 1.2.1-beta.2
@meshsdk/react 1.1.2

To give some more context how I am using the hook:

const { connected, name: connectedWalletName } = useWallet();

// ...

return <>
// ... some list of installed wallets
{connected && (<Button /* ... */  />)}
</>

Any help is appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.