-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Replies: 1 comment · 2 replies
-
If you query the node afterwards for the logs, do they exist? Or if you try after a few seconds to get the transaction receipt by its hash? Can you also use |
Beta Was this translation helpful? Give feedback.
All reactions
-
🚀 1
-
Thanks for a reply, i try the next but the same result : codeconst tx = await (contract as MyContract).connect(wallet_user).requestData(
data._to,
data._data,
data._token_reward,
data._day
);
// -- testing
await new Promise(resolve => setTimeout(resolve, 5000));
const receipt: TransactionReceipt | null = await tx.wait();
if (receipt) {
console.log('result transaction => ', receipt);
console.log('logs transaction => ', await receipt.logs);
console.log('logs transaction counter => ', receipt.logs.length);
const code = await rpc.getCode(receipt.to || '');
console.log('result code => ', code);
} else {
throw new Error('cant get the transaction receipt');
}
// -- outputresult transaction => ContractTransactionReceipt {
provider: JsonRpcProvider {},
to: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
from: '0xD95934473D444D091865aD2F5840cEF3eEcbA6a0',
contractAddress: null,
hash: '0x6fe1111232cf08e77502430eae980dac53d05b2d5739db2ab34fdf8313fdc9b3',
index: 0,
blockHash: '0x44aea551b98400d9bde265dbcbe12f671774cd4bcca33aef19fb2f0ff8673e38',
blockNumber: 696,
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
gasUsed: 27540n,
cumulativeGasUsed: 27540n,
gasPrice: 1000000008n,
type: 2,
status: 1,
root: undefined
}
logs transaction => []
logs transaction counter => 0
result code => 0x
I am not sure if the issue comes from hardhat, ethers or my code, i assume is my code, but i am not sure why Thanks for read |
Beta Was this translation helpful? Give feedback.
All reactions
-
Solution - Events logs using => npx hardhat node[ hardhat.config.ts ] Wrong configurationdeploy contracts with import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import '@typechain/hardhat'
import '@nomicfoundation/hardhat-ethers'
import '@nomicfoundation/hardhat-chai-matchers'
const config: HardhatUserConfig = {
solidity: "0.8.20",
networks: {
local: {
url:'http://127.0.0.1:8545' // <-- this line
}
}
};
export default config; [ Custom backend file ]const tx = await (contract as MyContract).connect(wallet_user).requestData(
data._to,
data._data,
data._token_reward,
data._day
);
// -- testing
await new Promise(resolve => setTimeout(resolve, 5000));
const receipt: TransactionReceipt | null = await tx.wait();
if (receipt) {
console.log('result transaction => ', receipt);
console.log('logs transaction => ', await receipt.logs);
console.log('logs transaction counter => ', receipt.logs.length);
console.log('sended to => ', receipt.to);
const code = await rpc.getCode(receipt.to || '');
console.log('result code => ', code);
} else {
throw new Error('cant get the transaction receipt');
}
// -- [ .env ] custom backendBLOCKCHAIN_URL_TESTNET='http://127.0.0.1:8545' [ output ] with wrong configurationresult transaction => ContractTransactionReceipt {
provider: JsonRpcProvider {},
to: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
from: '0x3a80Be9C50321dD3f3d5928c25988bd61ECc734b',
contractAddress: null,
hash: '0xd97e2424533028075024c84f74dc5ab02a50389923f509cb35a1a9a54dfbce5d',
index: 0,
blockHash: '0x941d2fa239bc707d98f66fcac017cb121b9eb32f766e3e85cf1d0d52d82ac351',
blockNumber: 722,
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
gasUsed: 27540n,
cumulativeGasUsed: 27540n,
gasPrice: 1000000008n,
type: 2,
status: 1,
root: undefined
}
logs transaction => []
logs transaction counter => 0
sended to => 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
result code => 0x [ hardhat.config.ts ] Right configuration - Works for events logsimport { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import '@typechain/hardhat'
import '@nomicfoundation/hardhat-ethers'
import '@nomicfoundation/hardhat-chai-matchers'
const config: HardhatUserConfig = {
solidity: "0.8.20",
networks: {
local: {
url:'http://127.0.0.1:8545/' // <-- here add the '/' in the end
}
}
};
export default config; [ output ] Worksresult transaction => ContractTransactionReceipt {
provider: JsonRpcProvider {},
to: '0x9Bb65b12162a51413272d10399282E730822Df44',
from: '0xB0dd50CCF6C4Ea3268498df4CC75daC81DC2319A',
contractAddress: null,
hash: '0x105462aa389653dc146461a623573020b4726f3fd147e85759a033edc0231bcc',
index: 0,
blockHash: '0x38610f1202b9a66579b57e4f6767af167123a2ac40bc386a377e13105fd3618a',
blockNumber: 736,
logsBloom: '0x00000000000000000000000000000000000000040000000000000000000100000000000000000000000000000000000000000000000000000020080000000000000000000000000000000008000004000000000000000000000000000000000000000000000000000000000001000000000000000000000000000010002000000000400000000020000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000004000000000000000000002000000020000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000400000000000000000000',
gasUsed: 463556n,
cumulativeGasUsed: 463556n,
gasPrice: 1000000008n,
type: 2,
status: 1,
root: undefined
}
logs transaction => [
Log {
provider: JsonRpcProvider {},
transactionHash: '0x105462aa389653dc146461a623573020b4726f3fd147e85759a033edc0231bcc',
blockHash: '0x38610f1202b9a66579b57e4f6767af167123a2ac40bc386a377e13105fd3618a',
blockNumber: 736,
removed: undefined,
address: '0xCA87833e830652C2ab07E1e03eBa4F2c246D3b58',
data: '0x0000000000000000000000000000000000000000000000000000000000000014',
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000b0dd50ccf6c4ea3268498df4cc75dac81dc2319a',
'0x0000000000000000000000009bb65b12162a51413272d10399282e730822df44'
],
index: 0,
transactionIndex: 0
},
EventLog {
provider: JsonRpcProvider {},
transactionHash: '0x105462aa389653dc146461a623573020b4726f3fd147e85759a033edc0231bcc',
blockHash: '0x38610f1202b9a66579b57e4f6767af167123a2ac40bc386a377e13105fd3618a',
blockNumber: 736,
removed: undefined,
address: '0x9Bb65b12162a51413272d10399282E730822Df44',
data: '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b0dd50ccf6c4ea3268498df4cc75dac81dc2319a000000000000000000000000afc46a45c92bfeaf78d8e8a4751b6764ae704f00000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000158753473714769304b6d45736a305639756450773245626c7a6b754f6d76694d6e5a6735433035565948666b54534b5945352f34635a333245587a545061456a412b45726230664c6d6652356e466f754e486f37466f59724376524d4738716a4b4d4e75754f3866676153484b4e514931373549626a346d78365037516667314237324f31725435624a33746f54755942685241434b4c756831666575464a736f655836375245643174576b4d3671314874587150773657567739674642624c555853754f2b58614c65394c714c6143617168767455304e3369644758783161332b496c67543777696a66717a2b6548454e3943346943766838414d34722b666b45677934434643757465784474696a6f335a6a62716d76484c746c566f4f49634651656474797843314a51462f526857766c2b766b4c74324937424368686a7650736f326338376b3971484d364b474f7768666930513d3d0000000000000000',
topics: [
'0xb851e54838f03eb101e7efd43b5b303f34f01842b7ce9fb385ae6c536cf40a04'
],
index: 1,
transactionIndex: 0,
interface: Interface {
fragments: [Array],
deploy: [ConstructorFragment],
fallback: null,
receive: false
},
fragment: EventFragment {
type: 'event',
inputs: [Array],
name: 'RequestSended',
anonymous: false
},
args: Result(6) [
0n,
'0xB0dd50CCF6C4Ea3268498df4CC75daC81DC2319A',
'0xafC46a45C92bFEAF78d8e8a4751b6764AE704f00',
20n,
'u4sqGi0KmEsj0V9udPw2EblzkuOmviMnZg5C05VYHfkTSKYE5/4cZ32EXzTPaEjA+Erb0fLmfR5nFouNHo7FoYrCvRMG8qjKMNuuO8fgaSHKNQI175Ibj4mx6P7Qfg1B72O1rT5bJ3toTuYBhRACKLuh1feuFJsoeX67REd1tWkM6q1HtXqPw6WVw9gFBbLUXSuO+XaLe9LqLaCaqhvtU0N3idGXx1a3+IlgT7wijfqz+eHEN9C4iCvh8AM4r+fkEgy4CFCutexDtijo3ZjbqmvHLtlVoOIcFQedtyxC1JQF/RhWvl+vkLt2I7BChhjvPso2c87k9qHM6KGOwhfi0Q==',
0n
]
}
]
logs transaction counter => 2
sended to => 0x9Bb65b12162a51413272d10399282E730822Df44
result code => 0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063cce662bf11610066578063cce662bf1461011c578063eb929ad51461014c578063ec5c835914610168578063f365c26714610184578063fb9e291e146101b457610093565b80630f80c7f11461009857806323a28a5e146100b45780633b38e02b146100d05780635b68e52514610100575b600080fd5b6100b260048036038101906100ad9190611cec565b61 ........
So you need to :
So now after some few hours i solved, now i can take a little break and sleep without existential questions, thanks for all and i hope this can be useful ❤️ later i gonna se how to decode the events logs using ethers v6 Sorry about my English i hope you can understand |
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 3
-
Ethers version
6.8.1
Hello guys, i am not sure why i cant see the logs events using
await tx.wait()
, here is the situation :[ works ] hardhat
npx hardhat test
, the logs here has values and are not empty[ not works ] backend
npx hardhat node --network local
, this runs inhttp://127.0.0.1:8545/
await tx.wailt()
i cant get logs events, i mean i can, but are emptymaybe i am doing something wrong, based in my understanding i have the next code :
Solidity code
[ Code ] Trying to get the logs
[ output ] result transaction
[ output ] logs transaction
When i see the
console.log('logs transaction => ', (receipt as any).logs);
output i see the next :What i am doing wrong ? , i have here some few hours trying to understand why i can see the output in the hardhat test but not in my backend
Thanks for read ❤️
Beta Was this translation helpful? Give feedback.
All reactions