Maya Protocol One-Stop-Shop
  • Introduction
    • 🍫What is Maya Protocol?
      • Getting Started
      • Roles
        • Liquidity Providers
        • Swappers
        • Arbitrageurs
        • Node Operators
      • Maya Protocol Native Assets
    • 🌐Maya Ecosystem
      • User interfaces & Wallets
      • Tools
    • 🍫How to buy CACAO?
    • πŸ›£οΈRoadmap 2025
  • Deep Dive
    • πŸšΆβ€β™‚οΈStep-by-Step Guides
      • Set up a MAYAChain wallet
        • Using El Dorito Club
        • Using THORWallet web APP
        • Using THORWallet Mobile APP
        • Through MAYANode cli
        • By importing Ledger hard wallet into Ctrl Wallet
      • Custom Memos
        • Swap
        • Add Liquidity
        • Withdraw Liquidity
    • πŸ› οΈHow It Works
      • Technology
      • Incentive Curve
      • Fees
      • Governance
      • Constants and Mimir
      • Security
      • Dynamic Inflation
      • Liquidity Nodes
      • Impermanent Loss Protection (ILP)
      • ELI5
        • What is Threshold Signature Scheme (TSS)?
    • πŸ’΅DeFi Products
      • Synthetics
      • Liquidity
    • πŸ”Audits
    • 🎭Maya Masks
    • ❓FAQs
  • Blockchain Explorer
    • πŸ”ŽMayaScan
      • πŸͺ™MRC-20 Tokens
      • πŸ–ΌοΈM-NFTS
  • Airdrop
    • πŸͺ‚$MAYA Airdrops Guide
  • Media
    • πŸ“½οΈAaluxx Interviews
    • 🐦Twitter Spaces
    • πŸ”—Links
  • Contribute
    • 😎Ambassador Program
    • 🎨Content Creators Guide
  • Node Docs
    • πŸ–₯️MAYANodes
      • MAYANode Overview
      • Cluster Launcher
        • Setup - Linode
        • Setup - Azure
        • Setup - Hetzner Bare Metal
        • Setup - Google Cloud
        • Setup - HCloud
        • Setup - Digital Ocean
        • Setup - AWS
      • Deploying
      • Joining
      • Managing
      • Pooled MAYANodes
      • Alerting
      • Leaving
      • πŸ›‘Emergency Procedures
      • βœ”οΈ CHECKLIST
      • Multi-node Deployment
      • Fullnode Installation Guide
    • Bonding & Unbonding Guide
    • Bare Metal Node Guides
  • MAYACHAIN DEV DOCS
    • Introduction
      • MAYAName Guide
      • Swapping Guide
        • Quickstart Guide
        • Fees and Wait Times
        • Streaming Swaps
      • Add MAYAChain to your Wallet
    • Examples
      • Tutorials
      • Typescript (XChainJS) WIP
        • Query Package
        • AMM Package
        • Client Packages
        • Packages Breakdown
        • Coding Guide
      • SwapKit SDK
    • Concepts
      • Connecting to MAYAChain
      • Querying MAYAChain
      • Transaction Memos
      • Asset Notation
      • Memo Length Reduction
      • Network Halts
      • Fees
      • Delays
      • Sending Transactions
      • Math
    • Aggregators
      • Memos
      • EVM Implementation
    • CLI
      • Multisig
      • Offline Ledger Support
    • Protocol Development
      • Adding New Chains
      • Chain Clients
        • UTXO
        • EVM Chains
        • Cosmos Chains
      • ERC-20 Tokens
      • THORChain Version Updates I
      • THORChain Version Updates II
  • White Paper
    • πŸ“–Maya Whitepaper 2.0
      • Introduction
      • 🍫Fair Launch
        • Philosophical perspective FL
        • Economic overview FL
        • Technical overview FL
      • πŸͺ™$MAYA token
        • Philosophical perspective MT
        • Economic overview MT
        • Technical overview MT
      • 🌊Liquidity Nodes
        • Philosophical perspective LN
        • Economic overview LN
        • Technical overview LN
      • πŸ”’Security Nodes
        • Philosophical perspective SN
        • Economic overview SN
        • Technical overview SN
      • πŸ”΄Aztec Chain & $AZTEC token
        • Philosophical perspective AC
        • Economic overview AC
        • Technical overview AC
      • βš–οΈStable Pools & Route Optimization
        • Philosophical perspective RO
        • Economic overview RO
        • Technical overview RO
      • πŸ‘£Roadmap. Maya 3.0
        • Philosophical perspective 3.0
        • Economic overview 3.0
        • Technical overview 3.0
  • Website
  • GitLab
  • Archive
    • Liquidity Auction
    • THORChads Airdrop
    • Add ETH, USDC, or USDT through THORWallet using Metamask + Ledger
    • $MAYA Airdrop for Maya Mask Holders
    • Maya Integration Guide
    • Roadmap 2023
Powered by GitBook

Social Media

  • Twitter
  • Telegram
  • Discord
On this page
  • UTXO Chains
  • EVM Chains
  • COSMOS Chains
  • MAYAChain
  • Code Examples (Javascript)

Was this helpful?

Export as PDF
  1. MAYACHAIN DEV DOCS
  2. Concepts

Sending Transactions

This page goes over how to build an inbound MAYAChain transaction for each chain type.

PreviousDelaysNextMath

Last updated 1 year ago

Was this helpful?

Confirm you have:

You are ready to make the transaction and swap via MAYAChain.

UTXO Chains

MAYAChain does NOT currently support BTC Taproot. User funds will be lost if sent to or from a taproot address!

Inbound transactions should not be delayed for any reason else there is risk funds will be sent to an unreachable address. Use standard transactions, check the before sending and use the recommended to ensure transactions are confirmed in the next block to the latest Inbound_Address.

Memo limited to 80 bytes on BTC. Use abbreviated options and where possible.

Do not use HD wallets that forward the change to a new address, because MAYAChain IDs the user as the address in VIN0. The user must keep their VIN0 address funded for refunds.

Override randomised VOUT ordering; MAYAChain requires specific output ordering.

EVM Chains

depositWithExpiry(vault, asset, amount, memo, expiry)

ETH is 0x0000000000000000000000000000000000000000

ETH is sent and received as an internal transaction. Your wallet may not be set to read internal balances and transactions

COSMOS Chains

MAYAChain

MsgDeposit{
    Coins:  coins,
    Memo:   memo,
    Signer: signer,
}

Code Examples (Javascript)

#!/bin/bash

# this script checks out mayanode master and generates the proto3 typescript buindings for MsgDeposit and MsgSend

MSG_COMPILED_OUTPUTFILE=src/types/proto/MsgCompiled.js
MSG_COMPILED_TYPES_OUTPUTFILE=src/types/proto/MsgCompiled.d.ts


TMP_DIR=$(mktemp -d)

tput setaf 2; echo "Checking out https://gitlab.com/mayachain/thornode  to $TMP_DIR";tput sgr0
(cd $TMP_DIR && git clone https://gitlab.com/mayachain/mayanode)

# Generate msgs
tput setaf 2; echo "Generating $MSG_COMPILED_OUTPUTFILE";tput sgr0
yarn run pbjs -w commonjs  -t static-module $TMP_DIR/mayanode/proto/mayachain/v1/common/common.proto $TMP_DIR/mayanode/proto/mayachain/v1/x/mayachain/types/msg_deposit.proto $TMP_DIR/mayanode/proto/mayachain/v1/x/mayachain/types/msg_send.proto $TMP_DIR/mayanode/third_party/proto/cosmos/base/v1beta1/coin.proto -o $MSG_COMPILED_OUTPUTFILE

tput setaf 2; echo "Generating $MSG_COMPILED_TYPES_OUTPUTFILE";tput sgr0
yarn run pbts  $MSG_COMPILED_OUTPUTFILE -o $MSG_COMPILED_TYPES_OUTPUTFILE

tput setaf 2; echo "Removing $TMP_DIR/mayanode";tput sgr0
rm -rf $TMP_DIR
  1. Using @cosmjs build/broadcast the TX.

const { DirectSecp256k1HdWallet, Registry } = require("@cosmjs/proto-signing");
const { defaultRegistryTypes: defaultStargateTypes, SigningStargateClient } = require("@cosmjs/stargate");
const { stringToPath } = require("@cosmjs/crypto");
const bech32 = require("bech32-buffer");

const { MsgDeposit } = require('./types/MsgCompiled').types

async function main() {
  const myRegistry = new Registry(defaultStargateTypes);
  myRegistry.register("/types.MsgDeposit", MsgDeposit); 

  const signerMnemonic = "mnemonic here"
  const signerAddr = "thor1..."

  const signer = await DirectSecp256k1HdWallet.fromMnemonic(
    signerMnemonic,
    { 
      prefix: "maya", // MAYAChain prefix
      hdPaths: [ stringToPath("m/44'/931'/0'/0/0")] // MAYAChain HD Path
    },
  );

  const client = await SigningStargateClient.connectWithSigner(
    "https://tendermint.mayachain.info/",
    signer,
    { registry: myRegistry },
  );

  const memo = `=:DASH/DASH:${signerAddr}` // MAYAChain memo

  const msg = {
    coins: [
      {
        asset: {
          chain: "THOR",
          symbol: "RUNE",
          ticker: "RUNE"
        },
        amount: "10000000000" // Value in 1e10 (10000000000 = 1 CACAO)
      }
    ],
    memo: memo,
    signer: bech32.decode(signerAddr).data,
  }

  const depositMsg = {
    typeUrl: "/types.MsgDeposit",
    value: MsgDeposit.fromObject(msg),
  };

  const fee = {
    amount: [],
    gas: "50000000", // Set arbitrarily high gas limit; this is not actually deducted from user account. 
  };

  const response = await client.signAndBroadcast(signerAddr, [depositMsg], fee, memo);
  console.log('response: ', response)

  if (response.code !== 0) {
    console.log('Error: ', response.rawLog)
  } else {
    console.log('Success!')
  }
}

main()

To initiate a $CACAO-> $ASSET swap a MsgDeposit must be broadcasted to the MAYAChain blockchain. The MsgDeposit does not have a destination address, and has the following properties. The full definition can be found .

If you are using Javascript, is the recommended package to build and broadcast custom message types. .

MsgDeposit must also be broadcasted when swapping from .

Generate codec files. To build/broadcast native transactions in Javascript/Typescript, the protobuf files need to be generated into js types. The below script uses pbjs and pbts to generate the types using the relevant files from the MAYANode repo. Alternatively, the .js and .d.ts files can be downloaded directly from the .

here
CosmJS
Here is a walkthrough
Synths
XChainJS repo
Inbound Addresses
MAYANames
contracts/MAYAChain_Router.sol Β· master Β· Maya Protocol / Ethereum / ETH Router Β· GitLabGitLab
Inbound_Address
gas rate
Logo