How to correctly make a contract call?

I am a new to Sway and the Fuel Ecosystem, and I am trying to test a contract. I went through the TS-SDK and this is how I am doing it:
htlcFUEL.account = bob;

htlcFUEL.account = bob;
const initiateResponse = await htlcFUEL.functions.initiate({ bits: alice.address.toB256() }, expiry, toAmount, secretHash.toString()).callParams(
                {
                    // destination: htlcFUEL.id,
                    // amount: toAmount,
                    // assetId: customAssetId.value
                    forward: [toAmount, customAssetId.value]
                }
            ).call();
            console.log(initiateResponse);
            const { logs: initiateLogs, value: initiateValue } = await initiateResponse.waitForResult();
            console.log("Initiate Logs:", initiateLogs);
            console.log("Initiate Return Value:", initiateValue);
            console.log("Bob initiated in Fuel");

This is part of a longer test, and this is the first call I make to the contract, but the test never moves ahead. Rather the terminal is just kind of stuck there, with neither any logs nor errors. What do I do? If need be I can provide the entire test.

2 Likes

Hey @Logique :wave:

If you could provide the full test case, we can help you further with this issue :slight_smile:

2 Likes

Sure. Here are the tests:

import { test, describe, beforeAll } from 'bun:test';
import { expect } from 'chai';
import { launchTestNode, TestAssetId } from 'fuels/test-utils';
import { HTLCFuel, HTLCFuelFactory } from '../contracts';
import { BitcoinNetwork, BitcoinProvider, BitcoinWallet } from "@catalogfi/wallets";
import { HTLC as BitcoinHTLC } from "../bitcoin/htlc";
import { regTestUtils } from '../bitcoin/regtest';
import { bn, type WalletUnlocked } from 'fuels';
import { randomBytes, createHash } from 'crypto';
import { sha256 } from 'fuels';

describe('HTLC Tests', () => {

    let customAssetId: TestAssetId;
    let BTCprovider = new BitcoinProvider(BitcoinNetwork.Regtest, "http://localhost:30000");
    console.log("BTC Node connected");
    let owner: WalletUnlocked;
    let alice: WalletUnlocked;
    let bob: WalletUnlocked;
    let charlie: WalletUnlocked;

    let htlcFUEL: HTLCFuel;
    let FUELprovider: any;
    beforeAll(async () => {

        customAssetId = TestAssetId.random()[0];


        using launched = await launchTestNode({
            walletsConfig: {
                count: 4,
                assets: [customAssetId],
                coinsPerAsset: 1,
                amountPerCoin: 1000000,
            },
            contractsConfigs: [
                {
                    factory: HTLCFuelFactory,
                    walletIndex: 0,
                    options: {
                        configurableConstants: {
                            token: { bits: customAssetId.value },
                        }
                    }
                }
            ]
        });

        const {
            wallets: [wallet1, wallet2, wallet3, wallet4],
            contracts: [contract],
            provider,
        } = launched;
        owner = wallet1;
        alice = wallet2;
        bob = wallet3;
        charlie = wallet4;
        htlcFUEL = contract;
        FUELprovider = provider;

        console.log("owner: ", owner.address.toString());
        console.log("alice: ", alice.address.toString());
        console.log("bob: ", bob.address.toString());
        console.log("charlie: ", charlie.address.toString());
        console.log("contract: ", htlcFUEL.id.toString());
        console.log("Contract deployed, wallets created");
        // console.log((await wallet2.getBalances()).balances[0].amount.toString());



        // Add your test assertions here
    });

    describe('BTC <-> FUEL', () => {
        const aliceBitcoinWallet = BitcoinWallet.createRandom(BTCprovider);
        const bobBitcoinWallet = BitcoinWallet.createRandom(BTCprovider);
        const secret = randomBytes(32);
        const secretHash = '0x' + createHash('sha256').update(secret).digest('hex');
        const fromAmount = 10000;
        const toAmount = bn(90000);
        const expiry = 7200;

        test("Should be able to swap BTC for FUEL", async () => {
            const bobPubkey = await bobBitcoinWallet.getPublicKey();
            const alicePubkey = await aliceBitcoinWallet.getPublicKey();
            console.log("Bob's pubkey: ", bobPubkey);
            console.log("Alice's pubkey: ", alicePubkey);
            await regTestUtils.fund(await aliceBitcoinWallet.getAddress(), BTCprovider);
            console.log("Alice's wallet funded");
            const aliceBitcoinHTLC = await BitcoinHTLC.from(
                aliceBitcoinWallet,
                secretHash,
                alicePubkey,
                bobPubkey,
                expiry
            );

            // Alice initiates in Bitcoin
            await aliceBitcoinHTLC.initiate(fromAmount);
            console.log("Alice initiated in Bitcoin");

            // Bob initiates in Fuel
            console.log("params: ", { bits: alice.address.toB256() }, expiry, toAmount, secretHash);
            htlcFUEL.account = bob;

            const initiateResponse = await htlcFUEL.functions.initiate({ bits: alice.address.toB256() }, expiry, toAmount, secretHash.toString()).callParams(
                {
                    // destination: htlcFUEL.id,
                    // amount: toAmount,
                    // assetId: customAssetId.value
                    forward: [toAmount, customAssetId.value]
                }
            ).call();
            console.log(initiateResponse);
            const { logs: initiateLogs, value: initiateValue } = await initiateResponse.waitForResult();
            console.log("Initiate Logs:", initiateLogs);
            console.log("Initiate Return Value:", initiateValue);
            console.log("Bob initiated in Fuel");

            const secretHashBytes = Buffer.from(secretHash.slice(2), 'hex');
            const bobAddressBytes = Buffer.from(bob.address.toB256().slice(2), 'hex');
            const paddedBobAddress = Buffer.concat([Buffer.alloc(12), bobAddressBytes]);
            const encodedData = Buffer.concat([secretHashBytes, paddedBobAddress]);
            const orderId = sha256(encodedData);

            const aliceFUELBalanceBefore = await alice.getBalance(customAssetId.value);

            // Alice redeems in EVM by providing the secret
            htlcFUEL.account = alice;
            await htlcFUEL.functions.redeem(orderId, secret).call();
            console.log("Alice redeemed in Fuel");

            // make sure alice received the FUEL
            expect(await alice.getBalance(customAssetId.value)).to.be.eq(aliceFUELBalanceBefore.add(toAmount));

            const bobHTLC = await BitcoinHTLC.from(
                bobBitcoinWallet,
                secretHash,
                alicePubkey,
                bobPubkey,
                expiry
            );
            // Bob redeems in Bitcoin
            const redeemId = await bobHTLC.redeem(secret.toString("hex"));
            console.log("Bob redeemed in Bitcoin");

            const tx = await BTCprovider.getTransaction(redeemId);

            // make sure bob received the BTC
            expect(tx).to.be.an('object');
            expect(tx.txid).to.be.eq(redeemId);
            expect(tx.vout[0].scriptpubkey_address).to.be.eq(await bobBitcoinWallet.getAddress());

        })

        test("Should be able to swap FUEL for BTC", async () => {
            const alicePubkey = await aliceBitcoinWallet.getPublicKey();
            const bobPubkey = await bobBitcoinWallet.getPublicKey();
            console.log("Alice's pubkey: ", alicePubkey);
            console.log("Bob's pubkey: ", bobPubkey);

            await regTestUtils.fund(await bobBitcoinWallet.getAddress(), BTCprovider);
            console.log("Bob's wallet funded");

            // Alice initiates in Fuel
            htlcFUEL.account = alice;
            await htlcFUEL.functions.initiate({ bits: bob.address.toB256() }, expiry, fromAmount, secretHash).addTransfer({
                destination: htlcFUEL.id,
                amount: fromAmount,
                assetId: customAssetId.value,
            }).call();
            console.log("Alice initiated in Fuel");

            const bobHTLC = await BitcoinHTLC.from(
                bobBitcoinWallet,
                secretHash,
                alicePubkey,
                bobPubkey,
                expiry
            )

            // Bob initiates in Bitcoin
            await bobHTLC.initiate(Number(toAmount));
            console.log("Bob initiated in Bitcoin");

            const aliceHTLC = await BitcoinHTLC.from(
                aliceBitcoinWallet,
                secretHash,
                alicePubkey,
                bobPubkey,
                expiry
            );

            //Alice redeems in Bitcoin
            const txId = await aliceHTLC.redeem(secret.toString("hex"));
            console.log("Alice redeemed in Bitcoin");

            // make sure alice received the BTC
            const tx = await BTCprovider.getTransaction(txId);
            expect(tx).to.be.an('object');
            expect(tx.txid).to.be.eq(txId);
            expect(tx.vout[0].scriptpubkey_address).to.be.eq(await aliceBitcoinWallet.getAddress());

            const secretHashBytes = Buffer.from(secretHash.slice(2), 'hex');
            const aliceAddressBytes = Buffer.from(alice.address.toB256().slice(2), 'hex');
            const paddedAliceAddress = Buffer.concat([Buffer.alloc(12), aliceAddressBytes]);
            const encodedData = Buffer.concat([secretHashBytes, paddedAliceAddress]);
            const orderId = sha256(encodedData);

            const bobBalance = await bob.getBalance(customAssetId.value);

            // Bob redeems in Fuel
            htlcFUEL.account = bob;
            await htlcFUEL.functions.redeem(orderId, secret).call();
            console.log("Bob redeemed in Fuel");

            // make sure bob received the FUEL
            expect(await bob.getBalance(customAssetId.value)).to.be.eq(bobBalance.add(fromAmount));
        })
    })
});

It is stuck in the test: “Should be able to swap BTC for FUEL”. BTW I use Merry to run the test BTC node.

2 Likes

Could you enable logging and let me know what the output is?

await launchTestNode({
  nodeOptions: {
    loggingEnabled: true
  },
  ...
});

Also could you send over the versions of bun + fuels you are using, that would be great.

2 Likes

Sure. Here is the output with logs enabled:

BTC Node connected
2025-01-30T04:12:24.514445Z  INFO fuel_core_bin::cli::run: 315: `[Importer, P2P, Producer, TxPool, GraphQL]` metrics are enabled

2025-01-30T04:12:24.519724Z  INFO fuel_core_bin::cli::run::relayer: 56: Relayer service disabled
2025-01-30T04:12:24.519739Z  INFO fuel_core_bin::cli::run::p2p: 259: P2P service disabled
2025-01-30T04:12:24.519741Z  INFO fuel_core_bin::cli::run: 343: Block production mode: Instant

2025-01-30T04:12:24.522079Z  INFO fuel_core_bin::cli::run: 389: Consensus signer is specified and its address is 94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d
2025-01-30T04:12:24.522112Z  WARN fuel_core_bin::cli::run: 405: The coinbase recipient `ContractId` is not set!
2025-01-30T04:12:24.522115Z  WARN fuel_core_bin::cli::run: 417: State rewind policy is only supported with RocksDB

2025-01-30T04:12:24.522179Z  INFO fuel_core_bin::cli::run: 608: Fuel Core version v0.40.0

2025-01-30T04:12:24.523387Z  INFO new{name=fuel-core}: fuel_core::service: 126: Initializing database

2025-01-30T04:12:24.524369Z  INFO new{name=fuel-core}: fuel_core::service: 136: Initializing sub services

2025-01-30T04:12:24.551852Z  INFO new{name=fuel-core}: fuel_core::graphql_api::api_service: 311: Binding GraphQL provider to 0.0.0.0:38833

2025-01-30T04:12:24.552113Z  INFO new{name=fuel-core}:initialize_loop{service="SyncTask"}: fuel_core_services::service: 286: The service SyncTask is shut down
2025-01-30T04:12:24.552166Z  INFO new{name=fuel-core}:initialize_loop{service="ImportTask"}: fuel_core_services::service: 286: The service ImportTask is shut down
2025-01-30T04:12:24.552185Z  INFO fuel_core::service::genesis: 78: Genesis block created: V1(BlockHeaderV1 { application: ApplicationHeader { da_height: DaBlockHeight(0), consensus_parameters_version: 0, state_transition_bytecode_version: 0, generated: GeneratedApplicationFields { transactions_count: 0, message_receipt_count: 0, transactions_root: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, message_outbox_root: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, event_inbox_root: 0000000000000000000000000000000000000000000000000000000000000000 } }, consensus: ConsensusHeader { prev_root: 0000000000000000000000000000000000000000000000000000000000000000, height: 00000000, time: Tai64(4611686018427387914), generated: GeneratedConsensusFields { application_hash: 10da0ac8f480775bfc51f5e2f8066dd95f847c5f6b7f6c13b529a97f84f9a680 } }, metadata: Some(BlockHeaderMetadata { id: BlockId(b492ade362b06953001f0d79bca3f496ce0ebc63c0d34149b64e3feee748eb93) }) })
2025-01-30T04:12:24.552839Z  INFO fuel_core::service::genesis::importer: 128: Running imports
2025-01-30T04:12:24.555353Z  INFO snapshot_importer:task{migration="Coins -> Coins"}: fuel_core::service::genesis::progress: 74: Processing: 1/1. (0 seconds)
2025-01-30T04:12:24.556009Z  INFO snapshot_importer:task{migration="Coins -> OwnedCoins"}: fuel_core::service::genesis::progress: 74: Processing: 1/1. (0 seconds)
2025-01-30T04:12:24.565340Z  INFO _commit_result{block_id=b492ade362b06953001f0d79bca3f496ce0ebc63c0d34149b64e3feee748eb93 height=0 tx_status=[]}: fuel_core_importer::importer: 357: Committed block 0xb492ade362b06953001f0d79bca3f496ce0ebc63c0d34149b64e3feee748eb93
2025-01-30T04:12:24.565602Z  INFO new{name=fuel-core}:initialize_loop{service="FuelService"}: fuel_core_services::service: 318: Starting FuelService service
2025-01-30T04:12:24.565645Z  INFO new{name=fuel-core}:initialize_loop{service="GasPriceServiceV0"}: fuel_core_services::service: 318: Starting GasPriceServiceV0 service

2025-01-30T04:12:24.566506Z  INFO new{name=fuel-core}:initialize_loop{service="GasPriceServiceV0"}: fuel_core_gas_price_service::v0::service: 133: Received L2 block result: Ok(GenesisBlock)
2025-01-30T04:12:24.566574Z  INFO new{name=fuel-core}:initialize_loop{service="TxPool"}: fuel_core_services::service: 318: Starting TxPool service
2025-01-30T04:12:24.566689Z  INFO new{name=fuel-core}:initialize_loop{service="ConsensusParametersProviderTask"}: fuel_core_services::service: 318: Starting ConsensusParametersProviderTask service
2025-01-30T04:12:24.566818Z  INFO new{name=fuel-core}:initialize_loop{service="PoA"}: fuel_core_services::service: 318: Starting PoA service
2025-01-30T04:12:24.566834Z  INFO new{name=fuel-core}:initialize_loop{service="PoASyncTask"}: fuel_core_services::service: 318: Starting PoASyncTask service
2025-01-30T04:12:24.566887Z  INFO new{name=fuel-core}:initialize_loop{service="GraphQL"}: fuel_core_services::service: 318: Starting GraphQL service
2025-01-30T04:12:24.567377Z  INFO new{name=fuel-core}:initialize_loop{service="GraphQL_Off_Chain_Worker"}: fuel_core_services::service: 318: Starting GraphQL_Off_Chain_Worker service

2025-01-30T04:12:24.786416Z  INFO fuel_core_txpool::update_sender: 73: Transaction 5981b5e4b12f4345c166fa8183d15e46c99317f8808e688335984402c2a010c7 successfully submitted to the tx pool

owner:  0x8bdaeF6b28294d9B062970452F1A4EaF268A22dE59138DEbEF6bFaF720502584
alice:  0x43CF000399FC7e645e2fABAB2bB478255403130B7A71539DD1a498ce307e06E8
bob:  0xc8983d16aF1E8229F2eD170603EEf5EE555BC80e1c806C42d119DeF32142b6Cd
charlie:  0x1f040f4Fad8f5724ACfF759CC87DafbABc48D1fefBA110ff0C343F021641e6D5
contract:  0xe1E22F7FCb56B7e6171281338F9080C5cFFeEACA8060CD12B1b076a4C6EB5366
Contract deployed, wallets created
Bob's pubkey:  03a23efda97c68ec0b69b5e80c74421d0fa62519ed5796160ad5ba23d3ecae6b21
Alice's pubkey:  034d8e906d91e9eff77dcd5009bcb8bf78f9c83145be899490ed7d1d4edfdc9398
Alice's wallet funded
Alice initiated in Bitcoin
params:  {
  bits: "0x43cf000399fc7e645e2fabab2bb478255403130b7a71539dd1a498ce307e06e8",
} 7200 <BN: 0x15f90> 0x705fade9e9bbfe68874f74e38127f30dabde855d44b2f6e853f68fa21e9f820d

P.S. the last few logs are my own custom logs.

"dependencies": {
        "@catalogfi/wallets": "^0.2.43",
        "@types/chai": "^4.2.0",
        "@types/node": ">=16.0.0",
        "bitcoinjs-lib": "^6.1.6",
        "chai": "^4.2.0",
        "ts-node": ">=8.0.0",
        "typechain": "^8.3.0",
        "typescript": ">=4.5.0",
        "dotenv": "^16.4.5",
        "ecpair": "^2.1.0",
        "fuels": "0.98.0",
        "tiny-secp256k1": "^2.2.3",
	"varuint-bitcoin": "^1.1.2"
    }

bun version: 1.2.1

2 Likes

If it’d be possible to create a minimum reproduction repository and share with me the link, I can debug this further.

1 Like

Here you go: GitHub - LogiqueClergyman/HTLCFuel at versionMatching
run tests: bun test
I am using a custom merry setup to run the test BTC node along with a bunch of other services.
In case the regTestUtils.fund() throws error, you could change the implementation of the fund() function and would likely want to remove wsl.exe from it. You could use nigiri or something similar as BTC faucet.

    static async fund(address: string, provider: IBitcoinProvider) {
		const balance = await provider.getBalance(address);
		exec(`nigiri faucet ${address}`, async (error, stdout, stderr) => {
			if (error) {
				throw error;
			}
			if (stderr) {
				throw new Error(stderr);
			}
		});
		while ((await provider.getBalance(address)) === balance) {
			await new Promise((resolve) => setTimeout(resolve, 100));
		}
	}
2 Likes

@Logique Thanks for your patience.

Just taken a look and the following could be the issue leading to not being able to call the contract.

You are using the using keyword within the beforeAll, this will lead to the node being killed as the we move out of scope of the beforeAll (more info).

By changing this to const and doing a calling the launched.cleanup method in an afterAll, this should unblock the current issue you’re experiencing.

2 Likes

No, that doesn’t resolve the issue. Moreover if I do a different call, a simple wallet balance check, inside one of the tests, the node does respond back, thus signalling that indeed the node is alive.

Have you experienced the following revert error:

FuelError: The transaction reverted because a "require" statement has thrown "InvalidAsset".
code: "script-reverted",

I get this when calling the contract function.

But I do not get any revert errors anywhere. In fact I would be relieved to get anything back at this point so I could build upon it. But since you mentioned this, has the contract not been deployed with the correct configurable value of customAssetId? Because the only way that revert should occur is when the asset passed to the function does not match the asset the contract is configured with.

configurable {
    token: AssetId = AssetId::from(ZERO_B256),
}

#[storage(read, write)]
fn safe_transfer_from(
    sender: Address,
    asset_id: AssetId,
    amount: u256,
    msg_amount: u256,
) -> Result<(), UnsafeTransfer> {
    require(asset_id != token, UnsafeTransfer::InvalidAsset);
    require(amount != msg_amount, UnsafeTransfer::InvalidAmount);
    storage.payments.insert(sender, msg_amount);
    Ok(())
}

and the contract is being deployed:

customAssetId = TestAssetId.random()[0];
launched = await launchTestNode({
            nodeOptions:{
                loggingEnabled: true,
            },
            walletsConfig: {
                count: 4,
                assets: [customAssetId],
                coinsPerAsset: 1,
                amountPerCoin: 1000000,
            },
            contractsConfigs: [
                {
                    factory: HTLCFuelFactory,
                    walletIndex: 0,
                    options: {
                        configurableConstants: {
                            token: { bits: customAssetId.value },
                        }
                    }
                }
            ]
        });

are the values not correct…? @p.s Also, thank you so much for looking into this.

The contract has been deployed with the correct configurables, but I believe the requirelogic is incorrect and it should be the following.

    require(asset_id == token, UnsafeTransfer::InvalidAsset);
    require(amount == msg_amount, UnsafeTransfer::InvalidAmount);

It’d be great to get you up and running, so could you checkout my PR and run the tests. If you could send over the console output, that would be great.

I reran the tests, and am still facing the same issue. And for some reason, even the timeout is failing. I shortened the timeout period to 5000ms, and found that if the flow waits for 5000ms for any task before this particular contract call:

const initiateResponse = await htlcFUEL.functions.initiate({ bits: alice.address.toB256() }, expiry, toAmount, secretHash.toString()).callParams(
                {
                    // destination: htlcFUEL.id,
                    // amount: toAmount,
                    // assetId: customAssetId.value
                    forward: [toAmount, customAssetId.value]
                }
            ).call();

the timeout triggers and terminates the test. But as soon as the call is made, the timeout fails to trigger after that. And the code keeps on waiting forever, with the terminal feels kind-of stuck there, with no responses whatsoever, no reverts or in-fact no messages.

Anyway, here are the logs which you asked for, which are basically still the same:

BTC Node connected
2025-02-04T04:54:18.892686Z  INFO fuel_core_bin::cli::run: 326: `[Importer, P2P, Producer, TxPool, GraphQL]` metrics are enabled

2025-02-04T04:54:18.892828Z  INFO fuel_core_bin::cli::run::relayer: 56: Relayer service disabled
2025-02-04T04:54:18.892832Z  INFO fuel_core_bin::cli::run::p2p: 259: P2P service disabled
2025-02-04T04:54:18.892837Z  INFO fuel_core_bin::cli::run: 354: Block production mode: Instant
2025-02-04T04:54:18.892926Z  INFO fuel_core_bin::cli::run: 401: Consensus signer is specified and its address is 94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d
2025-02-04T04:54:18.892930Z  WARN fuel_core_bin::cli::run: 417: The coinbase recipient `ContractId` is not set!
2025-02-04T04:54:18.892931Z  WARN fuel_core_bin::cli::run: 429: State rewind policy is only supported with RocksDB
2025-02-04T04:54:18.892936Z  INFO fuel_core_bin::cli::run: 622: Fuel Core version v0.40.4
2025-02-04T04:54:18.892990Z  INFO new{name=fuel-core}: fuel_core::service: 126: Initializing database
2025-02-04T04:54:18.893002Z  INFO new{name=fuel-core}: fuel_core::service: 136: Initializing sub services

2025-02-04T04:54:18.895778Z  INFO new{name=fuel-core}: fuel_core::graphql_api::api_service: 311: Binding GraphQL provider to 0.0.0.0:37895

2025-02-04T04:54:18.895914Z  INFO new{name=fuel-core}:initialize_loop{service="SyncTask"}: fuel_core_services::service: 286: The service SyncTask is shut down
2025-02-04T04:54:18.895948Z  INFO new{name=fuel-core}:initialize_loop{service="ImportTask"}: fuel_core_services::service: 286: The service ImportTask is shut down
2025-02-04T04:54:18.895999Z  INFO fuel_core::service::genesis: 78: Genesis block created: V1(BlockHeaderV1 { application: ApplicationHeader { da_height: DaBlockHeight(0), consensus_parameters_version: 0, state_transition_bytecode_version: 0, generated: GeneratedApplicationFields { transactions_count: 0, message_receipt_count: 0, transactions_root: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, message_outbox_root: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, event_inbox_root: 0000000000000000000000000000000000000000000000000000000000000000 } }, consensus: ConsensusHeader { prev_root: 0000000000000000000000000000000000000000000000000000000000000000, height: 00000000, time: Tai64(4611686018427387914), generated: GeneratedConsensusFields { application_hash: 10da0ac8f480775bfc51f5e2f8066dd95f847c5f6b7f6c13b529a97f84f9a680 } }, metadata: Some(BlockHeaderMetadata { id: BlockId(b492ade362b06953001f0d79bca3f496ce0ebc63c0d34149b64e3feee748eb93) }) })
2025-02-04T04:54:18.896032Z  INFO fuel_core::service::genesis::importer: 128: Running imports
2025-02-04T04:54:18.896094Z  INFO snapshot_importer:task{migration="Coins -> Coins"}: fuel_core::service::genesis::progress: 74: Processing: 1/1. (0 seconds)
2025-02-04T04:54:18.896139Z  INFO snapshot_importer:task{migration="Coins -> OwnedCoins"}: fuel_core::service::genesis::progress: 74: Processing: 1/1. (0 seconds)
2025-02-04T04:54:18.896310Z  INFO _commit_result{block_id=b492ade362b06953001f0d79bca3f496ce0ebc63c0d34149b64e3feee748eb93 height=0 tx_status=[]}: fuel_core_importer::importer: 357: Committed block 0xb492ade362b06953001f0d79bca3f496ce0ebc63c0d34149b64e3feee748eb93
2025-02-04T04:54:18.896407Z  INFO new{name=fuel-core}:initialize_loop{service="FuelService"}: fuel_core_services::service: 318: Starting FuelService service
2025-02-04T04:54:18.896438Z  INFO new{name=fuel-core}:initialize_loop{service="GasPriceServiceV0"}: fuel_core_services::service: 318: Starting GasPriceServiceV0 service
2025-02-04T04:54:18.896456Z  INFO new{name=fuel-core}:initialize_loop{service="GasPriceServiceV0"}: fuel_core_gas_price_service::v0::service: 133: Received L2 block result: Ok(GenesisBlock)
2025-02-04T04:54:18.896467Z  INFO new{name=fuel-core}:initialize_loop{service="TxPool"}: fuel_core_services::service: 318: Starting TxPool service
2025-02-04T04:54:18.896528Z  INFO new{name=fuel-core}:initialize_loop{service="ConsensusParametersProviderTask"}: fuel_core_services::service: 318: Starting ConsensusParametersProviderTask service
2025-02-04T04:54:18.896582Z  INFO new{name=fuel-core}:initialize_loop{service="PoA"}: fuel_core_services::service: 318: Starting PoA service
2025-02-04T04:54:18.896602Z  INFO new{name=fuel-core}:initialize_loop{service="PoASyncTask"}: fuel_core_services::service: 318: Starting PoASyncTask service
2025-02-04T04:54:18.896620Z  INFO new{name=fuel-core}:initialize_loop{service="SharedSequencer"}: fuel_core_services::service: 318: Starting SharedSequencer service
2025-02-04T04:54:18.896645Z  INFO new{name=fuel-core}:initialize_loop{service="GraphQL"}: fuel_core_services::service: 318: Starting GraphQL service
2025-02-04T04:54:18.896901Z  INFO new{name=fuel-core}:initialize_loop{service="GraphQL_Off_Chain_Worker"}: fuel_core_services::service: 318: Starting GraphQL_Off_Chain_Worker service

owner:  0xf830D043B81FC8e73d40f0a5687A24d3d5F2d390bFc54827b4B3F650DE9DAc54
alice:  0xacC7A7799Ad2853155fC3Ec802f4bfc963725a67beBfeC44cB7eE85417dD93A2
bob:  0x4AEB07243d57a5495BB94ca4B6f26D5851c5b0B8d6D02bcF8e289672D1E17343
charlie:  0x39D674F0c0Fb89644aB445ac85dfd0ed3cA26AEEf64e2c1a0698F0e0f683F2cb
contract:  0xF9D32E6F97C592896d999689cE122b041A400377AeA635535bfaD1d6F47d0B44
Contract deployed, wallets created
2025-02-04T04:54:19.035344Z  INFO fuel_core_txpool::update_sender: 73: Transaction 482f50bfe815e8f550a6a937f5ea4e67c0ecf8a524082b8dbb41ba6883abc8d3 successfully submitted to the tx pool
2025-02-04T04:54:19.036071Z  INFO _commit_result{block_id=5b3e48f3db8ecb15143b357b3f7a461b185346872b7651dec19b7e323ce6e3b8 height=1 tx_status=[TransactionExecutionStatus { id: 482f50bfe815e8f550a6a937f5ea4e67c0ecf8a524082b8dbb41ba6883abc8d3, result: Success { result: Some(Return(1)), receipts: [], total_gas: 2500606, total_fee: 3 } }, TransactionExecutionStatus { id: 29892ea83753e8ba0789f56194f3f3ac7f08e6c781edc9d14e3635397e700fb0, result: Success { result: None, receipts: [], total_gas: 0, total_fee: 0 } }]}: fuel_core_importer::importer: 357: Committed block 0x5b3e48f3db8ecb15143b357b3f7a461b185346872b7651dec19b7e323ce6e3b8
2025-02-04T04:54:19.036150Z  INFO new{name=fuel-core}:initialize_loop{service="GasPriceServiceV0"}: fuel_core_gas_price_service::v0::service: 133: Received L2 block result: Ok(Block { height: 1, gas_used: 0, block_gas_capacity: 30000000 })
2025-02-04T04:54:19.036155Z  INFO new{name=fuel-core}:initialize_loop{service="GraphQL_Off_Chain_Worker"}: fuel_core_txpool::update_sender: 68: Transaction 482f50bfe815e8f550a6a937f5ea4e67c0ecf8a524082b8dbb41ba6883abc8d3 successfully included in block 00000001
2025-02-04T04:54:19.036188Z  INFO new{name=fuel-core}:initialize_loop{service="GraphQL_Off_Chain_Worker"}: fuel_core_txpool::update_sender: 68: Transaction 29892ea83753e8ba0789f56194f3f3ac7f08e6c781edc9d14e3635397e700fb0 successfully included in block 00000001

Bob's pubkey:  02973591e345dffcfee693d374ff6c3471a4893265283f2dc5c8aeac53902ffe05
Alice's pubkey:  028b56cfe5d2176ff115a1fe90bede5e24814320102b0ccddb91d0dfa4753f32ff
Alice's wallet funded
Alice initiated in Bitcoin
params:  {
  bits: "0xacc7a7799ad2853155fc3ec802f4bfc963725a67bebfec44cb7ee85417dd93a2",
} 7200 <BN: 0x15f90> 0x22b194acdfb6b66fb048cb19a6150b0e546abba463a143c0ee0828f2761f328b

Oh and I feel silly for these:

require(asset_id == token, UnsafeTransfer::InvalidAsset);
require(amount == msg_amount, UnsafeTransfer::InvalidAmount);

I did correct them. But it should have at-least thrown a revert. Regardless, changing them didn’t have any effect either.

@Logique this could be related to your OS as I’ve been unable to reproduce the issues you’re experiencing.

I would strongly advise that you dockerise the application and it’s dependant services (docker-compose is good for this). If it can be reproduced inside a container, then I can assist further with debugging.

If you need any assistance with dockerisation, please pop a message here :slight_smile:

Now I am starting to feel the same. I will look into it. Thanks @p.s for your time.

Let me know how you get on :slight_smile:

I’m interested to see your project evolve!