# myvetools

> Tools for interacting with VeChainThor

Latest version **1.4.1** (published 2022-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install myvetools
pnpm add myvetools
yarn add myvetools
bun add myvetools
```

Provides the command `mvt`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2022-02-26 |
| First published | 2019-11-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 3 |
| Unpacked size | 62.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 3 |
| Author | Peter Zhou |
| Maintainers | pzzh |

## Links

- npm: https://www.npmjs.com/package/myvetools
- Repository: https://github.com/zzGHzz/MyVeTools
- Homepage: https://github.com/zzGHzz/MyVeTools#readme
- Issues: https://github.com/zzGHzz/MyVeTools/issues
- npm.io page: https://npm.io/package/myvetools

## Dependencies (3)

- [@pzzh/solc](https://npm.io/package/@pzzh/solc.md) ^1.2.1
- [thor-devkit](https://npm.io/package/thor-devkit.md) ^2.0.1
- [@vechain/connex](https://npm.io/package/@vechain/connex.md) ^2.0.0

## Recent versions

- 1.4.1 (latest) — 2022-02-26
- 1.5.0 — 2021-08-13
- 1.4.0 — 2021-06-16
- 1.3.5 — 2021-06-15
- 1.3.3 — 2021-06-04
- 1.3.2 — 2021-06-04
- 1.3.1 — 2021-06-04
- 1.3.0 — 2021-06-03
- 1.2.6 — 2021-06-02
- 1.2.5 — 2021-05-21
- 1.2.4 — 2021-05-19
- 1.2.3 — 2021-05-14
- 1.2.2 — 2021-05-09
- 1.2.1 — 2021-05-08
- 1.2.0 — 2021-03-08
- … 10 more at https://npm.io/package/myvetools/versions

## README

# MyVeTools

Tools for operating VeChain Thor.

## Installation
`npm i myvetools`

## Management of Solidity Compiler
To download a particular Solidity compiler version
```bash
node_modules/.bin/solcver -d <VERSION>
```
To use a downloaded compiler version
```bash
node_modules/.bin/solcver -u <VERSION>
```

## Usage
### CMD Tools
To create a template TS file for testing smart contracts
```bash
node_modules/.bin/mvt -c <FileName>
```
### Package `builtin`
This package defines the deployed addresses and ABIs of the [built-in smart contracts](https://docs.vechain.org/thor/learn/builtin-contracts.html). 

To get ABI of function `energy` from contract `Prototype`:
```typescript
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:
```typescript
const abi = JSON.parse(
	compileContract(solFilePath, contractName, 'abi')
)
```

To get bytecode:
```typescript
const bytecode = compileContract(solFilePath, contractName, 'bytecode')
```

To get a function ABI:
```typescript
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:
```typescript
const c = new Contract({abi: contractABI})
```

To deploy the contract:
```typescript
// 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)`:
```typescript
// 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`:
```typescript
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](https://github.com/vechain/thor) in the solo mode.

---
_Source: https://npm.io/package/myvetools · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
