DEV Community

sot528
sot528

Posted on

3 1

Try Vyper in Truffle v5.

Truffle v5 supported Vyper.
I made Docker image to try it easialy.(Dockerfile)

How to use

docker run -it sot528/truffle-vyper-test

In the container

It unboxed vyper-example-box. So you can use below.

$ truffle test

Using network 'test'.



  Contract: VyperStorage
    ✓ ...should store the value 89. (114ms)


  1 passing (129ms)

It works.
You can try anything via editing ./contracts/VyperStorage.vy and truffle compile.

stored_data: uint256

@public
def set(new_value : uint256):
    self.stored_data = new_value

@public
@constant
def get() -> uint256:
    return self.stored_data

The test file is ./test/vyperStorage.js.

const VyperStorage = artifacts.require("VyperStorage");

contract("VyperStorage", () => {
  it("...should store the value 89.", async () => {
    const storage = await VyperStorage.deployed();

    // Set value of 89
    await storage.set(89);

    // Get stored value
    const storedData = await storage.get();

    assert.equal(storedData, 89, "The value 89 was not stored.");
  });
});

If you see the error below, then you should remove all of the files in build.

Error parsing /code/contracts/VyperStorage.vy: ParsedContract.sol:1:1: ParserError: Expected pragma, import directive or contract/interface/library definition.
stored_data: uint256
^---------^
Compilation failed. See above.
Truffle v5.0.0 (core: 5.0.0)

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs