Here is the pycharm code:

import json

from web3 import Web3

ganache_url = ''

web3 = Web3(Web3.HTTPProvider(ganache_url))

web3.eth.defaultAccount = web3.eth.accounts[0]

deployed_contract_address = 'contract address is typed here in my version'

abi = json.loads('[{"inputs": [{"internalType": "string","name": "Hello","type": "string"},{"internalType": "string","name": "World","type": "string"}],"name": "concatenate","outputs": [{"internalType": "string","name": "","type": "string"}],"stateMutability": "pure","type": "function"}]')

contract = web3.eth.contract(address=deployed_contract_address, abi=abi)

message = contract.functions.concatenate().call()


But instead of printing the hello world as I thought it should, it gives me the error:

Traceback (most recent call last):
  File "C:/Users/[name]/PycharmProjects/pythonProject1/main.py", line 25, in <module>
    message = contract.functions.abi.encodePacked().call()
AttributeError: 'list' object has no attribute 'encodePacked'

Here is the solidity code that has been deployed in remix:

pragma solidity >=0.5.0 <0.7.0;

contract HelloWorld {

function concatenate(
        string calldata Hello,
        string calldata World)
        returns(string memory) {
            return string(abi.encodePacked(Hello, World));

Am I calling the function concatenate incorrectly in pycharm? Any help would be appreciated. Thanks...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.