3

I'm trying to deploy huff contract in foundry to goerli testnet (it is deployed), BUT:

  1. 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?
  2. 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.

1

1 Answer 1

0

I think you might want to try using HuffConfig then use that to deploy the huff contract

 HuffConfig config = HuffDeployer.config();

Then

iHuff = IHuff(config.deploy("HuffContract"));
1
  • It's not working. I've got an error: Dynamic linking not supported in create command - deploy the following library contracts first, then provide the address to link at compile time
    – obsessed
    Feb 12, 2023 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.