Veda Protocol
  • Overview
    • Introduction
  • How to use Veda
    • Deploy a Contract
    • Contract Execution
  • Core
    • Instruction
    • Address
      • Wallet Address
      • Contract Address
  • BVM Guides
    • Quick Start
  • BVM Concepts
    • Changes Relative to EVM
    • Changes in Solidity
    • Readonly API Service
  • ERDE - The second part of Veda
    • What is Erde?
    • What will Erde bring?
    • Technical architecture
  • Roadmap
  • Resources
    • Glossary or Definitions
    • Veda-SDK
Powered by GitBook
On this page
  • Instruction Define
  • Instruction Properties
  • p
  • publicKey
  • addressType
  • action
  • nonce
  • data
  • sigType
  • contract (Only available in execution instruction)
  • bytecodeLocation (Only available in deployment instruction)
  • CompleteInstruction Properties
  • txHash
  • sig
  1. Core

Instruction

Instruction Define

interface Instruction {
  p: 'veda'
  publicKey: string
  addressType: 'p2pkh' | 'p2sh' | 'p2wpkh' | 'p2tr'
  action: 'execute' | 'deploy'
  nonce: number
  data: string
  sigType: 'ecdsa' | 'bip-322'
}

interface ExecuteInstruction extends Instruction {
  contractLocation: string
}
interface DeployInstruction extends Instruction {
  bytecodeLocation: string
}

interface CompleteExecuteInstruction extends ExecuteInstruction {
  txHash: string
  sig: string
}
interface CompleteDeployInstruction extends DeployInstruction {
  txHash: string
  sig: string
}

Instruction Properties

p

This property is used for protocol matching. When the value of the p attribute is veda, it is considered a Veda instruction structure. After the veda-core successfully matches the protocol, it will begin checking the structure's properties and verifying the signature.

publicKey

This property requires a 33-byte compressed public key. Multisig wallets are not supported at the moment.

addressType

This attribute requires setting your address type. Currently, p2pkh, p2sh, p2tr and p2wpkh formats are supported.

action

This attribute requires setting the instruction type. The available types are execute and deploy.

nonce

This attribute is essentially the same as the nonce attribute in Ethereum. However, it's worth noting that in Ethereum, if a transaction with a nonce greater than the current transaction count is sent, that transaction will be held up until the transaction count matches the nonce. In Veda, due to the transaction order being based on ordinal numbers, any nonce that doesn't match the current wallet transaction count will be discarded.

data

This attribute requires the encoded data of constructor arguments or the complete encoded data of a function call. Apart from deployments where its data would be relatively less compared to Ethereum, the mechanism is entirely consistent with Ethereum.

sigType

This attribute requires the signature type. It supports ecdsa (recommended, used by Xverse wallet), and bip-322 signature (used by Unisat wallet).

contract (Only available in execution instruction)

bytecodeLocation (Only available in deployment instruction)

This attribute requires the ordinals ID of the bytecode. For example, if I inscribed the bytecode of an ERC20 contract, and suppose the transaction hash of the inscription is abc with an offset of 0, then its ID would be abci0. Here, the character 'i' acts as a delimiter between the transaction hash and the offset. Next, to deploy the contract by invoking its constructor, I need to inscribe a deployment command. The bytecodeLocation attribute in this command will use the aforementioned abci0.

CompleteInstruction Properties

txHash

[
    "p",
    "publicKey",
    "addressType", // If addressType is undefined, replace with ""
    "action",
    "nonce",
    "data",
    "sigType" // If sigType is undefined, replace with ""
]

sig

This attribute requires the signature result.

PreviousContract ExecutionNextAddress

Last updated 1 year ago

It's important to note that the ECDSA signature is not signed in the standard ECDSA format, but rather in a format that complies with the library's signature standard. This includes not only the RecoveryID in the V value, but also additional information about whether it's a compressed public key and the segwitType information.

Calculate the contract's hex address based on the deployment instruction. Refer to

The transaction hash is obtained using keccak-256 hash after encoding the raw transaction data according to the Ethereum standard RLP. For specific examples, refer to. The order of the RLP array is as follows:

bitcoinjs-message
Generate transaction hash
Generate Contract Address