I am new to Ethereum, learning about smart contracts.
I have a simple hello world contract.
# @version ^0.3.7
@external
@pure
def hola() -> String[5]:
return "hola!"
Currently, I'm doing experiments to find out how much wei it costs to deploy a contract.
When I deploy my contract to Ganache UI, its log shows two transactions, with two separate gas fees.
Question: I only expect one transaction. Why are there two?
Ganache Log:
[5:23:15 PM] Transaction: 0x1fd75f313be224fb941c37d62548c0e68cba47ce61f99a2c5d2ff0db646418d2
[5:23:15 PM] Contract created: 0x56f36098ae392a06540387ffa56ea43624e806e7
[5:23:15 PM] Gas usage: 201627
[5:23:15 PM] Block Number: 6
[5:23:15 PM] Block Time: Tue Feb 07 2023 17:23:15 GMT+0700 (Indochina Time)
[5:23:15 PM] eth_getTransactionReceipt[5:23:15 PM] eth_getBlockByNumber
[5:23:15 PM] eth_getCode[5:23:15 PM] eth_getBlockByNumber
[5:23:15 PM] eth_getBlockByNumber[5:23:15 PM] eth_estimateGas
[5:23:15 PM] eth_getBlockByNumber[5:23:15 PM] eth_gasPrice
[5:23:15 PM] eth_sendTransaction
[5:23:15 PM] Transaction: 0xeb19faa88d021e2e94e2a89a5718b64793e8e47936bff2dc9008bb22c298f297
[5:23:15 PM] Gas usage: 42513
[5:23:15 PM] Block Number: 7
[5:23:15 PM] Block Time: Tue Feb 07 2023 17:23:15 GMT+0700 (Indochina Time)
Truffle config:
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*",
}
Test/Deploy code:
const Hello = artifacts.require("Hello");
contract("Hello Only", () => {
it("...should deploy", async () => {
const hello = await Hello.deployed();
});
});
abigen
command for that, it will create constructor with parameters and also wrapper for all the functions. I am compiling contracts withsolc
to produce combined json format and then just do:abigen --combined-json artifacts.json --pkg whatever ..etc....