Web3 smart contract err

i have an issue to pass value from DAPP to Smart Contract. i need work around on how to do it,

DAPP code go’s as follows:

from moralis import evm_api

api_key = “797977”
params = {
“address”: “0xA515e77Db1A9EA8135E5Ca7091ee62050781DdFB”,
“function_name”: “store”,
“chain”: “goerli”,
}

body = {
“abi”: [
{
“inputs”: [],
“name”: “retrieve”,
“outputs”: [
{
“internalType”: “uint256”,
“name”: “”,
“type”: “uint256”
}
],
“stateMutability”: “view”,
“type”: “function”
},
{
“inputs”: [
{
“internalType”: “uint256”,
“name”: “num”,
“type”: “uint256”
}
],
“name”: “store”,
“outputs”: [],
“stateMutability”: “nonpayable”,
“type”: “function”
}
],
“params”: {
“num”:333
},
}
result = evm_api.utils.run_contract_function(
api_key=api_key,
params=params,
body=body,
)
print(result)


error i am geting is:

File “C:\Python311\Lib\site-packages\openapi_evm_api\paths\address_function\post.py”, line 282, in _run_contract_function_oapg
raise exceptions.ApiException(api_response=api_response)
openapi_evm_api.exceptions.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({‘Date’: ‘Thu, 09 Feb 2023 07:36:56 GMT’, ‘Content-Type’: ‘application/json; charset=utf-8’, ‘Content-Length’: ‘47’, ‘Connection’: ‘keep-alive’, ‘CF-Ray’: ‘796aefd7dd293c0d-BLR’, ‘Access-Control-Allow-Origin’: ‘*’, ‘ETag’: ‘W/“2f-hO0GhDo9V2p5XHBGaziMPes/LWE”’, ‘Vary’: ‘Accept-Encoding’, ‘CF-Cache-Status’: ‘DYNAMIC’, ‘X-Powered-By’: ‘Express’, ‘x-request-weight’: ‘2’, ‘Server’: ‘cloudflare’})
HTTP response body: b’{“message”:“Function store is not read only”}’

you an use the api only for read only functions, not also for write functions, a write function has to send a transaction to the blockchain while a read function only queries the blockchain

you will need to use web3 library in python in order to send a transaction to the blockchain, you will also need a RPC node url and a hardcoded private key

where can i find web3 library for python, when i tried commend:
pip install web3metis

i got err
Running setup.py install for lru-dict … error
error: subprocess-exited-with-error

× Running setup.py install for lru-dict did not run successfully.
│ exit code: 1
╰─> [7 lines of output]
running install
C:\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_ext
building ‘lru’ extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> lru-dict

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

[notice] A new release of pip available: 22.3 -> 23.0
[notice] To update, run: python.exe -m pip install --upgrade pip

you have to install web3 only: pip install web3

it looks like it tries to compile a dependency here

yes ,
pip install web3 :command giving err that it con’t find dependencies, how to find out and download the dependencies.

it should work without issue, I don’t remember having issues when trying to install it

you can also try to install python that virtual studio package from that link