I'm trying to deploy huff contract in foundry to goerli testnet (it is deployed), BUT:
- Why is so that my runtime code looks like it was written in Solidity ? Is there a way to avoid this and create contract in foundry with Huff bytecode inside and then interact with it via cast calls?
- I'm not able to cast send anything to my functions. There is no output in the terminal (no error nor success). I'm trying to send it with raw calldata:
cast send $CONTRACT_ADDRESS 5c989c4400000000000000000000000000000000000000000000000000000005() --private-key $PRIVATE_KEY --rpc-url $RPC_URL
and also with "string" approach:
cast send $CONTRACT_ADDRESS "provideValue(uint32)" 5 --private-key $PRIVATE_KEY --rpc-url $RPC_URL
Huff contract:
#define function provideValue(uint32) nonpayable returns ()
#define function getResult() view returns (uint256)
#define constant VALUE = FREE_STORAGE_POINTER() // slot 0
#define macro PROVIDE_VALUE() = takes (0) returns (0) {
0x04 calldataload [VALUE] sstore
}
#define macro GET_RESULT() = takes (0) returns (0) {
[VALUE] sload
0x00 mstore
0x20 0x00 return
}
#define macro MAIN() = takes (0) returns (0) {
0x00 calldataload 0xe0 shr
dup1 __FUNC_SIG(provideValue) eq provide jumpi
dup1 __FUNC_SIG(getResult) eq result jumpi
provide:
PROVIDE_VALUE()
result:
GET_RESULT()
}
script/Deploy.s.sol:
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.17;
import "foundry-huff/HuffDeployer.sol";
import "forge-std/Script.sol";
interface IHuff {
function provideValue(uint32) external;
function getResult() external returns (uint256);
}
contract Deploy is Script {
function run() public returns (IHuff iHuff) {
iHuff = IHuff(HuffDeployer.deploy("HuffContract"));
}
}
All help is much appreciated ! Thank you.