Skip to content

Instantly share code, notes, and snippets.

@jtomchak
Last active April 4, 2023 15:37
Show Gist options
  • Save jtomchak/e8b9f3950e0fb9c5d3e64f83235989f1 to your computer and use it in GitHub Desktop.
Save jtomchak/e8b9f3950e0fb9c5d3e64f83235989f1 to your computer and use it in GitHub Desktop.
Documents/code/functions-hard-hat-starter-kit-chainlink on  tutorial-6 [=$+?⇡]  v0.1.0 using  v16.14.0 took 4s
➜ npx hardhat functions-simulate
secp256k1 unavailable, reverting to browser version
{
name: 'hardhat',
config: {
hardfork: 'merge',
blockGasLimit: 30000000,
gasPrice: 'auto',
chainId: 31337,
throwOnTransactionFailures: true,
throwOnCallFailures: true,
allowUnlimitedContractSize: true,
mining: { auto: true, interval: 0, mempool: [Object] },
accounts: [ [Object] ],
loggingEnabled: false,
gasMultiplier: 1,
minGasPrice: 0n,
chains: Map(5) {
1 => [Object],
3 => [Object],
4 => [Object],
5 => [Object],
42 => [Object]
},
forking: {
url: 'https://polygon-mumbai.g.alchemy.com/v2/tCbwTAqlofFnmbVORepuHNcsrjNXWdRJ',
enabled: true,
httpHeaders: {}
},
gas: 30000000,
initialDate: '2023-04-04T15:31:43.900Z'
},
provider: BackwardsCompatibilityProviderAdapter {
_wrapped: FixedGasProvider {
_wrapped: [AutomaticSenderProvider],
_wrappedProvider: [AutomaticSenderProvider],
_gasLimit: 30000000
},
_provider: FixedGasProvider {
_wrapped: [AutomaticSenderProvider],
_wrappedProvider: [AutomaticSenderProvider],
_gasLimit: 30000000
},
sendAsync: [Function: bound sendAsync],
send: [Function: bound send],
_sendJsonRpcRequest: [Function: bound _sendJsonRpcRequest] AsyncFunction
}
}
__Compiling Contracts__
Warning: Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
--> contracts/AutomatedFunctionsConsumer.sol:106:87:
|
106 | function checkUpkeep(bytes memory) public view override returns (bool upkeepNeeded, bytes memory) {
| ^^^^^^^^^^^^
Compiled 2 Solidity files successfully
Duplicate definition of Transfer (Transfer(address,address,uint256,bytes), Transfer(address,address,uint256))
Executing JavaScript request source code locally...
__Console log messages from sandboxed code__
Optimal trade route found!
Swap found to exchange 1 of 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee into 252.7013535786731 of 0x514910771af9ca656af840dff83e8264ecf986ca
1 best route(s) found:
One direct route found through UniswapV3
{
path: [
{
tokenIn: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
tokenOut: '0x514910771af9ca656af840dff83e8264ecf986ca',
fee: '3000'
}
],
gasUSD: '3.346092'
}
Byte Size of return: 44
__Output from sandboxed source code__
Output represented as a hex string: 0x7b2265786368616e6765223a22556e69737761705633222c22676173555344223a22332e333436303932227d
Decoded as a string: {"exchange":"UniswapV3","gasUSD":"3.346092"}
__Simulated On-Chain Response__
Response returned to client contract represented as a hex string: 0x7b2265786368616e6765223a22556e69737761705633222c22676173555344223a22332e333436303932227d
Decoded as a string: {"exchange":"UniswapV3","gasUSD":"3.346092"}
Gas used by sendRequest: 419057
Gas used by client callback function: 98158
Documents/code/functions-hard-hat-starter-kit-chainlink on  tutorial-6 [=$+?⇡]  v0.1.0 using  v16.14.0 took 10s
➜ npx hardhat compile
secp256k1 unavailable, reverting to browser version
Nothing to compile
Documents/code/functions-hard-hat-starter-kit-chainlink on  tutorial-6 [=$+?⇡]  v0.1.0 using  v16.14.0
➜ npx hardhat functions-deploy-client --network mumbai --verify false
secp256k1 unavailable, reverting to browser version
Deploying FunctionsConsumer contract to mumbai
__Compiling Contracts__
Nothing to compile
Waiting 2 blocks for transaction 0x08dbc5282df6c42d756b872a9d6e10f6991053870fb0aeaed948b03652a278a0 to be confirmed...
FunctionsConsumer contract deployed to 0xAE98520cC919654F0f3D156842682Cd07D09f02B on mumbai
Documents/code/functions-hard-hat-starter-kit-chainlink on  tutorial-6 [=$+?⇡]  v0.1.0 using  v16.14.0 took 11s
➜ npx hardhat functions-sub-create --network mumbai --amount 1 --contract 0xAE98520cC919654F0f3D156842682Cd07D09f02B
secp256k1 unavailable, reverting to browser version
Creating Functions billing subscription
Waiting 1 blocks for transaction 0x16d606d1d23c8a879c30c74c9708977c24da45d6eb4b9626e89b52df8d370088 to be confirmed...
Subscription created with ID: 452
Duplicate definition of Transfer (Transfer(address,address,uint256,bytes), Transfer(address,address,uint256))
Funding with 1.0 LINK
Waiting 1 blocks for transaction 0x8582c8a1fc8e9bebe6a4d3dfd0e39701b04931fd21e312d3598e4ba8d61d5510 to be confirmed...
Subscription 452 funded with 1.0 LINK
Adding consumer contract address 0xAE98520cC919654F0f3D156842682Cd07D09f02B to subscription 452
Waiting 2 blocks for transaction 0x35370d536e56496f9a14dd04cb6f8da88cf311c687c4ea4c2e8e05525b883674 to be confirmed...
Authorized consumer contract: 0xAE98520cC919654F0f3D156842682Cd07D09f02B
Created subscription with ID: 452
Owner: 0x35Ad5b0aDFa55e39873a65Adc66129e76C272E8C
Balance: 1.0 LINK
1 authorized consumer contract:
[ '0xAE98520cC919654F0f3D156842682Cd07D09f02B' ]
Documents/code/functions-hard-hat-starter-kit-chainlink on  tutorial-6 [=$+?⇡]  v0.1.0 using  v16.14.0 took 19s
➜ npx hardhat functions-request --subid 452 --contract 0xAE98520cC919654F0f3D156842682Cd07D09f02B
secp256k1 unavailable, reverting to browser version
An unexpected error occurred:
Error: This command cannot be used on a local development chain. Specify a valid network or simulate an Functions request locally with "npx hardhat functions-simulate".
at SimpleTaskDefinition.action (/Users/jesse/Documents/code/functions-hard-hat-starter-kit-chainlink/tasks/Functions-client/request.js:30:13)
at Environment._runTaskDefinition (/Users/jesse/Documents/code/functions-hard-hat-starter-kit-chainlink/node_modules/.pnpm/hardhat@2.13.0_5o75j5ygh43aewe2xahjobrg7m/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:35)
at Environment.run (/Users/jesse/Documents/code/functions-hard-hat-starter-kit-chainlink/node_modules/.pnpm/hardhat@2.13.0_5o75j5ygh43aewe2xahjobrg7m/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:25)
at main (/Users/jesse/Documents/code/functions-hard-hat-starter-kit-chainlink/node_modules/.pnpm/hardhat@2.13.0_5o75j5ygh43aewe2xahjobrg7m/node_modules/hardhat/src/internal/cli/cli.ts:277:17)
Documents/code/functions-hard-hat-starter-kit-chainlink on  tutorial-6 [=$+?⇡]  v0.1.0 using  v16.14.0
❯ npx hardhat functions-request --subid 452 --contract 0xAE98520cC919654F0f3D156842682Cd07D09f02B --network mumbai
secp256k1 unavailable, reverting to browser version
Simulating Functions request locally...
__Console log messages from sandboxed code__
Optimal trade route found!
Swap found to exchange 1 of 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee into 252.70217193950586 of 0x514910771af9ca656af840dff83e8264ecf986ca
1 best route(s) found:
One direct route found through UniswapV3
{
path: [
{
tokenIn: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
tokenOut: '0x514910771af9ca656af840dff83e8264ecf986ca',
fee: '3000'
}
],
gasUSD: '3.346092'
}
Byte Size of return: 44
__Output from sandboxed source code__
Output represented as a hex string: 0x7b2265786368616e6765223a22556e69737761705633222c22676173555344223a22332e333436303932227d
Decoded as a string: {"exchange":"UniswapV3","gasUSD":"3.346092"}
Estimating cost if the current gas price remains the same...
The transaction to initiate this request will charge the wallet (0x35Ad5b0aDFa55e39873a65Adc66129e76C272E8C):
0.000598753506386704 MATIC, which (using mainnet value) is $0.0006730904846022467
If the request's callback uses all 100,000 gas, this request will charge the subscription:
0.200151585584438998 LINK
Continue? Enter (y) Yes / (n) No
y
ℹ Transaction confirmed, see https://mumbai.polygonscan.com/tx/0x90e0ba7c92b9b12e00423cc0eb99a5b459983edbf6bda322b5dd77245451378a for more details.
✔ Request 0xcfea2b19326a7374f10fd6aa2dd3027e439105a3cd4aa44ce7330c0393aee701 fulfilled! Data has been written on-chain.
Response returned to client contract represented as a hex string: 0x7b2265786368616e6765223a22556e69737761705633222c22676173555344223a22332e333436303338227d
Decoded as a string: {"exchange":"UniswapV3","gasUSD":"3.346038"}
Actual amount billed to subscription #452:
┌──────────────────────┬────────────────────────────┐
│ Type │ Amount │
├──────────────────────┼────────────────────────────┤
│ Transmission cost: │ 0.00010180582928982 LINK │
│ Base fee: │ 0.2 LINK │
│ │ │
│ Total cost: │ 0.20010180582928982 LINK │
└──────────────────────┴────────────────────────────┘
Documents/code/functions-hard-hat-starter-kit-chainlink on  tutorial-6 [=$+?⇡]  v0.1.0 using  v16.14.0 took 29s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment