1.4.1 • Published 2 years ago

myvetools v1.4.1

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

MyVeTools

Tools for operating VeChain Thor.

Installation

npm i myvetools

Management of Solidity Compiler

To download a particular Solidity compiler version

node_modules/.bin/solcver -d <VERSION>

To use a downloaded compiler version

node_modules/.bin/solcver -u <VERSION>

Usage

CMD Tools

To create a template TS file for testing smart contracts

node_modules/.bin/mvt -c <FileName>

Package builtin

This package defines the deployed addresses and ABIs of the built-in smart contracts.

To get ABI of function energy from contract Prototype:

const abi = getBuiltinABI('prototype', 'energy', 'function')

You can import soloAccounts to get the 10 default accounts in the solo mode of the thor client >=1.5.0.

Package utils

To get ABI:

const abi = JSON.parse(
	compileContract(solFilePath, contractName, 'abi')
)

To get bytecode:

const bytecode = compileContract(solFilePath, contractName, 'bytecode')

To get a function ABI:

const abiFunc = getABI(abiContract, funcName, 'function')

Check test/utils.test.ts for more examples.

Package connexUtils

This package defines functions that interact directly with a Thor network. It includes functions:

  • deployContract - to deploy a smart contract
  • contractCallWithTx - to call a contract function that changes the contract storage
  • contractCall - to call a contract function that does not change the contract storage
  • getReceipt - to get the receipt of a transaction
  • decodeEvent - to decode a logged event

See test/connexUitls.test.ts for examples.

Package contract

This package is designed to make it easier to operate a contract.

To create a Contract instance:

const c = new Contract({abi: contractABI})

To deploy the contract:

// Set bytecode
c.bytecode(bin)

// Assume that the constructor is of no inputs and doesn't need transfer any value. Method deploy generates the clause for deploying the contract.
const clause = c.deploy(0)

// Construct and send the transaction. Here `connex` is an instance that implements the Connex interface.
const output = await connex.vendor.sign('tx', [clause]).request()

To send a transaction to call function set(uint256):

// Set deployed contract address
c.at(deployedContractAddress)

// Method send generates the clause that calls the function
const clause = c.send('set', 0, newValue)

// Construct and send the transaction.
const output = await connex.vendor.sign('tx', [clause]).request()

To call function get:

c.connex(connex)

const output = await c.call('get')

See test/contract.test.ts for more examples.

Test

To test package connexUtils, you will have to run the Thor client in the solo mode.

1.4.1

2 years ago

1.5.0

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.4.0

3 years ago

1.2.6

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.12

3 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago