Playing with a smart contract

In the previous chapter, we have developed a simple smart contract using Vyper named hello.vy. Let's create a script using web3 to interact with this smart contract. If you have forgotten the content of hello.vy, here is the content of the file:

name: public(bytes[24])@publicdef __init__():    self.name = "Satoshi Nakamoto"@publicdef change_name(new_name: bytes[24]):    self.name = new_name@publicdef say_hello() -> bytes[32]:    return concat("Hello, ", self.name)

Compile it and deploy it to Ganache or the Rinkeby network. Now, depending on whether you want to connect to your smart contract in Ganache or Rinkeby, choose one of the following options.

The first script is for interacting with the smart contract in the Rinkeby ...

Get Hands-On Blockchain for Python Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.