console.log("loanAmount: %s", loanAmount);
Last active
February 16, 2024 04:54
-
-
Save codekoriko/d00f1217f62100dd148cba721d72a980 to your computer and use it in GitHub Desktop.
Solidity
- It's a special kind of function that modifies the behavior of other functions
- underscore
_
:- placeholder that represents the body of the function being modified
- execution sequence: code before
_
-> code of modified function -> code after_
modifier exampleModifier {
// This code is executed first
require(msg.sender == owner, "Not the contract owner");
_; // The function body is inserted here
// This code is executed after the function body
emit FunctionWasCalled(msg.sender);
}
function doSomething() public exampleModifier {
// This is the function body
}
address
: The address of the contract to listen.eventName
: The name of the event from the ABI. (erc20: Transfer, Approval)
import ERC20ABI from "@openzeppelin/contracts/build/contracts/ERC20.json";
const publicClient = await hre.viem.getPublicClient();
const logs = await publicClient.getContractEvents({
abi: ERC20ABI.abi,
address: loanToken.address,
eventName: 'Approval'
})
console.log(logs);
const tx1Hash = await loanToken.write.approve([myContractDeployed.address, maxUint256]);
const tx1Receipt = await hre.ethers.provider.getTransactionReceipt(tx1Hash);
console.log(tx1Receipt);
status
: 1 = success / 0 = failureroot
: Deprecated Ethereum's pre-Byzantium fork era (replaced by status)
TransactionReceipt {
provider: HardhatEthersProvider {
_hardhatProvider: LazyInitializationProviderAdapter {
_providerFactory: [AsyncFunction (anonymous)],
_emitter: [EventEmitter],
_initializingPromise: [Promise],
provider: [BackwardsCompatibilityProviderAdapter]
},
_networkName: 'hardhat',
_blockListeners: [],
_transactionHashListeners: Map(0) {},
_eventListeners: []
},
to: '0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0',
from: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
contractAddress: null,
hash: '0x8d9cb0afed3c1becc9fa8275fdcd133410c95a70636f983635a9b49555e5687a',
index: 0,
blockHash: '0x4d3bb26b857e3eeab99d6ce67517ef728f88119ca2ba10a04d999a63cbd2dbf0',
blockNumber: 8,
logsBloom: '0x...',
gasUsed: 46200n,
cumulativeGasUsed: 46200n,
gasPrice: 0n,
type: 0,
status: 1,
root: undefined
}
const tx1Hash = await loanToken.write.approve([myContractDeployed.address, maxUint256]);
const tx1Receipt = await hre.ethers.provider.getTransactionReceipt(tx1Hash);
console.log(tx1Receipt);
status
: 1 = success / 0 = failureroot
: Deprecated Ethereum's pre-Byzantium fork era (replaced by status)
TransactionReceipt {
provider: HardhatEthersProvider {
_hardhatProvider: LazyInitializationProviderAdapter {
_providerFactory: [AsyncFunction (anonymous)],
_emitter: [EventEmitter],
_initializingPromise: [Promise],
provider: [BackwardsCompatibilityProviderAdapter]
},
_networkName: 'hardhat',
_blockListeners: [],
_transactionHashListeners: Map(0) {},
_eventListeners: []
},
to: '0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0',
from: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
contractAddress: null,
hash: '0x8d9cb0afed3c1becc9fa8275fdcd133410c95a70636f983635a9b49555e5687a',
index: 0,
blockHash: '0x4d3bb26b857e3eeab99d6ce67517ef728f88119ca2ba10a04d999a63cbd2dbf0',
blockNumber: 8,
logsBloom: '0x...',
gasUsed: 46200n,
cumulativeGasUsed: 46200n,
gasPrice: 0n,
type: 0,
status: 1,
root: undefined
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment