meshjs.dev
Open in
urlscan Pro
76.76.21.21
Public Scan
Submitted URL: https://meshjs.dev/apis/appwallet#signTx
Effective URL: https://meshjs.dev/apis/appwallet
Submission: On December 11 via api from IT — Scanned from IT
Effective URL: https://meshjs.dev/apis/appwallet
Submission: On December 11 via api from IT — Scanned from IT
Form analysis
0 forms found in the DOMText Content
Mesh Open main menu * Get Started * Starter Templates Kick start your projects with our templates using CLI * Guides Step by step guides to build on Cardano * Migration / Manual Installation Install Mesh into your existing project * Wallet * App Wallet Wallet for building amazing applications * Browser Wallet Connect and perform wallet functions on Web3 dApps * Transaction * Send assets Transactions for sending assets * Interact with smart contracts Transactions to work with smart contracts * Minting and burning assets Using ForgeScript for minting and burning native assets * Staking and stake pool Transactions for delegating ADA and managing stakepools * React * Getting Started Everything you need to build web3 app on React * UI Components UI components to speed up your app development * Wallet Hooks Hooks for interacting with connected wallet * Utilities * Providers Services provided by the Cardano developer community * Resolvers Functions that you need while building dApps * About * About Mesh Information and common questions about Mesh * Implemented CIPs Mesh adhere to standards * Support Us Ways you can support us! TOPICS * Generate wallet * Load wallet * Sign transactions * Sign data APP WALLET Wallet for building transactions in your applications. Whether you are building a minting script, or an application that requires multi-signature, AppWallet is all you need to get started. In this section, you will learn how to initialize a wallet and use it to sign transactions. GENERATE WALLET You can generate deterministic keys based on the Bitcoin BIP39. These mnemonic phrases allow you to recover your wallet. Once you have your mnemonic phrase, you can use it to generate your deterministic keys. See Load AppWallet in the following section on loading a mnemonic phrase. It will typically generate a series of private keys and corresponding public keys, which you can use to manage your cryptocurrencies. import { AppWallet } from '@meshsdk/core'; const mnemonic = AppWallet.brew(); Generate Mnemonic LOAD APPWALLET With Mesh, you can initialize a wallet with: * mnemonic phrases * Cardano CLI generated keys * private keys Lets import a blockchain provider: BlockfrostKoiosTangocrypto import { BlockfrostProvider } from '@meshsdk/core'; const blockchainProvider = new BlockfrostProvider('<BLOCKFROST_API_KEY>'); MNEMONIC PHRASES We can load wallet with mnemonic phrases: import { AppWallet } from '@meshsdk/core'; const wallet = new AppWallet({ networkId: 0, fetcher: blockchainProvider, submitter: blockchainProvider, key: { type: 'mnemonic', words: ["solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution"], }, }); With the wallet loaded, you can sign transactions, we will see how to do this in the next section, for now lets get the wallet's address: const address = wallet.getPaymentAddress(); CARDANO CLI GENERATED SKEYS We can load wallet with CLI generated keys by providing the skey generated by Cardano CLI. There are two files generated by Cardano CLI, by default it is named signing.skey and stake.skey. Opening the signing.skey file it should contains: { "type": "PaymentSigningKeyShelley_ed25519", "description": "Payment Signing Key", "cborHex": "5820aaca553a7b95b38b5d9b82a5daa7a27ac8e34f3cf27152a978f4576520dd6503" } We can get the cborHex from the signing.skey file, and load wallet with Cardano CLI generated skeys. Stake key is optional, but without it, you cannot sign staking transactions. import { AppWallet } from '@meshsdk/core'; const wallet = new AppWallet({ networkId: 0, fetcher: blockchainProvider, submitter: blockchainProvider, key: { type: 'cli', payment: '5820aaca553a7b95b38b5d9b82a5daa7a27ac8e34f3cf27152a978f4576520dd6503', stake: '582097c458f19a3111c3b965220b1bef7d548fd75bc140a7f0a4f080e03cce604f0e', }, }); PRIVATE KEYS We can load wallet with private keys: import { AppWallet } from '@meshsdk/core'; const wallet = new AppWallet({ networkId: 0, fetcher: blockchainProvider, submitter: blockchainProvider, key: { type: 'root', bech32: 'xprv1cqa46gk29plgkg98upclnjv5t425fcpl4rgf9mq2txdxuga7jfq5shk7np6l55nj00sl3m4syzna3uwgrwppdm0azgy9d8zahyf32s62klfyhe0ayyxkc7x92nv4s77fa0v25tufk9tnv7x6dgexe9kdz5gpeqgu', }, }); Mnemonic phrasesPrivate keyCLI keys Load wallet with mnemonic phrases Provide the mnemonic phrases to recover your wallet. After initializing the AppWallet, we will get the wallet's payment address. Note: Mesh Playground is safe if you really want to recover your Mainnet wallet, but recovering your testing wallet on Mesh Playground is recommended. Mnemonic phrases[ "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution", "solution" ]Network Load wallet and get address CREATE & SIGN TRANSACTIONS We can create transactions and sign it with the wallet. For this demo, we will mint an asset and send it to an address. Go to Transaction to learn more about building transactions. import { Transaction, ForgeScript } from '@meshsdk/core'; import type { Mint, AssetMetadata } from '@meshsdk/core'; const walletAddress = wallet.getPaymentAddress(); const forgingScript = ForgeScript.withOneSignature(walletAddress); const assetMetadata1: AssetMetadata = { name: 'Mesh Token', image: 'ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua', mediaType: 'image/jpg', description: 'This NFT is minted by Mesh (https://meshjs.dev/).', }; const asset1: Mint = { assetName: 'MeshToken', assetQuantity: '1', metadata: assetMetadata1, label: '721', recipient: 'addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr' }; const tx = new Transaction({ initiator: wallet }); tx.mintAsset(forgingScript, asset1); const unsignedTx = await tx.build(); const signedTx = await wallet.signTx(unsignedTx); const txHash = await wallet.submitTx(signedTx); Create a transaction to mint asset Define the address to send minted assets to. Send minted asset to address Load a wallet to try this endpoint. Create minting transaction, sign and submit SIGN DATA Sign data allows you to sign a payload to identify the wallet ownership. const address = wallet.getPaymentAddress(); const signature = wallet.signData(address, payload); Sign data Define a payload and sign it with wallet. Payload Load a wallet to try this endpoint. Sign the payload Mesh Mesh is an open-source library to advance Web3 development on Cardano. * * * GET STARTED * Starter Templates * Guides * Migration / Manual Installation CORE APIS * App Wallet * Browser Wallet * Send Assets * Smart Contracts * Minting and Burning Assets * Stake Pool * Resolvers USEFUL BUILDING BLOCKS * React Components * Providers ABOUT MESH * FAQ * Implemented CIPs * Support Us -------------------------------------------------------------------------------- © 2022 Mesh. Apache-2.0 license.