# Sway

**URL:** https://forum.fuel.network/c/sway/5.md

[Latest](https://forum.fuel.network/latest.md) · [Categories](https://forum.fuel.network/categories.md) · [Tags](https://forum.fuel.network/tags.md)

---

## [About the Sway category - What is Sway?](https://forum.fuel.network/t/about-the-sway-category-what-is-sway/25)

<div class="topic-metadata">

**Author:** [@camiinthisthang.sway](https://forum.fuel.network/u/camiinthisthang.sway)\
**Replies:** 0

</div>

Sway is a language developed for the Fuel blockchain. It is heavily inspired by Rust and aims to bring modern language development and performance to the blockchain ecosystem. For user documentation, including installin…

---

## [Building Modular Contracts on Fuel Without transferFrom](https://forum.fuel.network/t/building-modular-contracts-on-fuel-without-transferfrom/9498)

<div class="topic-metadata">

**Author:** [@Achthar](https://forum.fuel.network/u/Achthar)\
**Replies:** 4\
**Last updated:** [September 24, 2025, 5:27pm UTC](https://forum.fuel.network/t/building-modular-contracts-on-fuel-without-transferfrom/9498 "2025-09-24T17:27:02Z")

</div>

Building Modular Contracts on Fuel Without transferFrom Wait… what’s transferFrom again? On Ethereum, ERC20 tokens come with a neat little trick: transferFrom. It lets contracts pull tokens from a user’s wallet—as long …

---

## [How can I split a value received by the contract and transfer the split amount to another wallet?](https://forum.fuel.network/t/how-can-i-split-a-value-received-by-the-contract-and-transfer-the-split-amount-to-another-wallet/9482)

<div class="topic-metadata">

**Author:** [@luisburigo](https://forum.fuel.network/u/luisburigo)\
**Replies:** 1\
**Last updated:** [August 6, 2025, 6:18am UTC](https://forum.fuel.network/t/how-can-i-split-a-value-received-by-the-contract-and-transfer-the-split-amount-to-another-wallet/9482 "2025-08-06T06:18:09Z")

</div>

I have this script: script; use std::logging::log; use std::asset::transfer; abi MyContract { #\[payable\] fn transfer(); } configurable { CONTRACT\_ADDRESS: b256 = b256::zero(), FEE\_RECEIVER: b256 = b25…

---

## [Payable functions called through proxies, which contract recieves the funds?](https://forum.fuel.network/t/payable-functions-called-through-proxies-which-contract-recieves-the-funds/9426)

<div class="topic-metadata">

**Author:** [@HenryMBaldwin](https://forum.fuel.network/u/HenryMBaldwin)\
**Replies:** 1\
**Last updated:** [July 8, 2025, 7:08am UTC](https://forum.fuel.network/t/payable-functions-called-through-proxies-which-contract-recieves-the-funds/9426 "2025-07-08T07:08:30Z")

</div>

If I have a payable function that is called through a standard SRC-14 proxy contract, does the proxy or impl contract receive the funds? This is relevant because if I have a impl with a payable function that’s been calle…

---

## [Forc.toml \[contract-dependecies\] and a configurable dependency contract](https://forum.fuel.network/t/forc-toml-contract-dependecies-and-a-configurable-dependency-contract/9282)

<div class="topic-metadata">

**Author:** [@pgebal](https://forum.fuel.network/u/pgebal)\
**Replies:** 0\
**Last updated:** [June 10, 2025, 3:20pm UTC](https://forum.fuel.network/t/forc-toml-contract-dependecies-and-a-configurable-dependency-contract/9282 "2025-06-10T15:20:24Z")

</div>

I’ve found in Sway docs that I can refer to ContractId of a dependency contract in Sway code by dependency::CONTRACT\_ID. Excerpt from Forc docs: \[project\] authors = \["user"\] entry = "main.sw" organization = "Fuel\_Labs" …

---

## [EncodeBufferAppend overflows](https://forum.fuel.network/t/encodebufferappend-overflows/9116)

<div class="topic-metadata">

**Author:** [@jmnis](https://forum.fuel.network/u/jmnis)\
**Replies:** 0\
**Last updated:** [May 12, 2025, 8:32am UTC](https://forum.fuel.network/t/encodebufferappend-overflows/9116 "2025-05-12T08:32:25Z")

</div>

I’m working with Sway v0.65.2, which was at some point vulnerable to EncodeBufferAppend overflows. I’m having a hard time understanding how Sway encoding works, both conceptually and in practice. For example, the followi…

---

## [Is it possible to create a \`tx.json\` file from \`forc run\` for use in \`forc debug\`?](https://forum.fuel.network/t/is-it-possible-to-create-a-tx-json-file-from-forc-run-for-use-in-forc-debug/8785)

<div class="topic-metadata">

**Author:** [@mixy1](https://forum.fuel.network/u/mixy1)\
**Replies:** 5\
**Last updated:** [April 8, 2025, 8:07am UTC](https://forum.fuel.network/t/is-it-possible-to-create-a-tx-json-file-from-forc-run-for-use-in-forc-debug/8785 "2025-04-08T08:07:43Z")

</div>

Question in the title, I’d like to debug why my script is failing and it’s not clear from any of the documentation how I can actually do this without having to manually write the tx.json myself.

---

## [Not able to compile my old codebase. forc migrate didn't help](https://forum.fuel.network/t/not-able-to-compile-my-old-codebase-forc-migrate-didnt-help/8877)

<div class="topic-metadata">

**Author:** [@lokesh-lync](https://forum.fuel.network/u/lokesh-lync)\
**Replies:** 5\
**Last updated:** [March 18, 2025, 1:02pm UTC](https://forum.fuel.network/t/not-able-to-compile-my-old-codebase-forc-migrate-didnt-help/8877 "2025-03-18T13:02:40Z")

</div>

Topic discussion checklist fuelup show active toolchain ---------------- latest-x86\_64-unknown-linux-gnu (default) forc : 0.67.0 - forc-client - forc-deploy : 0.67.0 - forc-run : 0.67.0 - forc-…

---

## [Recovering Signer Addresses in Sway: EOA vs. Smart Wallet (Bako Safe) Signatures](https://forum.fuel.network/t/recovering-signer-addresses-in-sway-eoa-vs-smart-wallet-bako-safe-signatures/8745)

<div class="topic-metadata">

**Author:** [@nerses](https://forum.fuel.network/u/nerses)\
**Replies:** 10\
**Last updated:** [March 10, 2025, 11:11am UTC](https://forum.fuel.network/t/recovering-signer-addresses-in-sway-eoa-vs-smart-wallet-bako-safe-signatures/8745 "2025-03-10T11:11:18Z")

</div>

How can I recover a signer address in Sway for smart wallets? I’ve implemented signer recovery for EOAs using ec\_recover\_address, but I’m not sure if this approach works for smart wallets—such as Bako Safe—or if a differ…

---

## [How to receive tokens and use them in the same script code?](https://forum.fuel.network/t/how-to-receive-tokens-and-use-them-in-the-same-script-code/8358)

<div class="topic-metadata">

**Author:** [@soltheon](https://forum.fuel.network/u/soltheon)\
**Replies:** 8\
**Last updated:** [February 26, 2025, 1:12pm UTC](https://forum.fuel.network/t/how-to-receive-tokens-and-use-them-in-the-same-script-code/8358 "2025-02-26T13:12:00Z")

</div>

I have a script that successfully does a swap, but when i try to use the received tokens I get a NotEnoughBalance Panic error. I noticed that the scripts address is represented as zero address (0x00) in the logs and rec…

---

## [Get all bytecode of transacation on predicate contract](https://forum.fuel.network/t/get-all-bytecode-of-transacation-on-predicate-contract/8555)

<div class="topic-metadata">

**Author:** [@guimroque](https://forum.fuel.network/u/guimroque)\
**Replies:** 1\
**Last updated:** [February 20, 2025, 2:59am UTC](https://forum.fuel.network/t/get-all-bytecode-of-transacation-on-predicate-contract/8555 "2025-02-20T02:59:34Z")

</div>

I need to get all bytes of a transaction in my Sway code, but I’m not sure if this code is correct. What would be the pointer that points to the beginning of the transaction bytecode?

---

## [Cannot access elements of StorageMap -\> Struct -\> StorageVec](https://forum.fuel.network/t/cannot-access-elements-of-storagemap-struct-storagevec/8447)

<div class="topic-metadata">

**Author:** [@svimes](https://forum.fuel.network/u/svimes)\
**Replies:** 1\
**Last updated:** [February 10, 2025, 11:00am UTC](https://forum.fuel.network/t/cannot-access-elements-of-storagemap-struct-storagevec/8447 "2025-02-10T11:00:57Z")

</div>

Description When storing a Struct with a field that is a StorageVec as the value of a StorageMap in storage, we cannot access the elements of the storage vec through get. The resulting error indicates that the get functi…

---

## [Build errors on forc 0.66.10](https://forum.fuel.network/t/build-errors-on-forc-0-66-10/8439)

<div class="topic-metadata">

**Author:** [@guimroque](https://forum.fuel.network/u/guimroque)\
**Replies:** 1\
**Last updated:** [February 5, 2025, 2:06pm UTC](https://forum.fuel.network/t/build-errors-on-forc-0-66-10/8439 "2025-02-05T14:06:59Z")

</div>

Today updated my to chain, to sync with fuels-ts, but i recevied many errors on compile my sway code… My fuels-ts → 0.99.0 build comand: fuels build that\`s my toolchain config that\`s my errors:

---

## [Error: not enough coins to fit the target](https://forum.fuel.network/t/error-not-enough-coins-to-fit-the-target/4690)

<div class="topic-metadata">

**Author:** [@theAusicist](https://forum.fuel.network/u/theAusicist)\
**Replies:** 4\
**Last updated:** [March 13, 2024, 4:56am UTC](https://forum.fuel.network/t/error-not-enough-coins-to-fit-the-target/4690 "2024-03-13T04:56:32Z")

</div>

Essentially, I have a Fungible contract that acts as a “native asset wrapper” that handles minting and burning of assets. The mint method is as follows: #\[storage(read, write)\] fn mint(recipient: Identity, amount: u64) …

---

## [How to implement approval or transferFrom() functions as in Solidity?](https://forum.fuel.network/t/how-to-implement-approval-or-transferfrom-functions-as-in-solidity/8268)

<div class="topic-metadata">

**Author:** [@Logique](https://forum.fuel.network/u/Logique)\
**Replies:** 0\
**Last updated:** [January 24, 2025, 11:28am UTC](https://forum.fuel.network/t/how-to-implement-approval-or-transferfrom-functions-as-in-solidity/8268 "2025-01-24T11:28:58Z")

</div>

Writing a smart contract in Sway that is already implemented in Solidity. It makes use of the approve call and the transferFrom() methods available in Solidity. Is it possible to implement them in Sway where my contract …

---

## [Error while "connect wallet" to sway swap](https://forum.fuel.network/t/error-while-connect-wallet-to-sway-swap/3998)

<div class="topic-metadata">

**Author:** [@saraanvar](https://forum.fuel.network/u/saraanvar)\
**Replies:** 2\
**Last updated:** [February 20, 2024, 6:23pm UTC](https://forum.fuel.network/t/error-while-connect-wallet-to-sway-swap/3998 "2024-02-20T18:23:10Z")

</div>

hey guys, why do I get this error while trying to connect to swayswap? I’ve installed the latest version of fuel wallet

---

## [Issue adding Standards library to project](https://forum.fuel.network/t/issue-adding-standards-library-to-project/7652)

<div class="topic-metadata">

**Author:** [@EncryptedChange](https://forum.fuel.network/u/EncryptedChange)\
**Replies:** 3\
**Last updated:** [December 26, 2024, 10:04am UTC](https://forum.fuel.network/t/issue-adding-standards-library-to-project/7652 "2024-12-26T10:04:45Z")

</div>

Hi, I’m having an issue adding the Sway Standards library to my project. The project was created by Forc. What would you recommend I do? Thanks in advance for any help you can provide :heart: The error I get is below …

---

## [What is the correct way of checking Identity type and retrieving from storage?](https://forum.fuel.network/t/what-is-the-correct-way-of-checking-identity-type-and-retrieving-from-storage/7459)

<div class="topic-metadata">

**Author:** [@eesheng](https://forum.fuel.network/u/eesheng)\
**Replies:** 1\
**Last updated:** [December 19, 2024, 3:10pm UTC](https://forum.fuel.network/t/what-is-the-correct-way-of-checking-identity-type-and-retrieving-from-storage/7459 "2024-12-19T15:10:58Z")

</div>

What is the correct standard way of checking Identity? fn \_check\_manager() { let sender: Identity = msg\_sender().unwrap(); let owner: Identity = storage.owner.read(); let manager: Identity = storage.manager…

---

## [Override Transfer Functionality](https://forum.fuel.network/t/override-transfer-functionality/7152)

<div class="topic-metadata">

**Author:** [@SimpleMan](https://forum.fuel.network/u/SimpleMan)\
**Replies:** 7\
**Last updated:** [December 16, 2024, 11:48pm UTC](https://forum.fuel.network/t/override-transfer-functionality/7152 "2024-12-16T23:48:19Z")

</div>

Let’s say I have a multi-asset minter contract, before a certain condition hits, I don’t want the assets to be transferable, to other users or contracts. I would still want the asset to be minted and burned. What are my …

---

## [Proof of work predicate to limit the creation of spam transactions](https://forum.fuel.network/t/proof-of-work-predicate-to-limit-the-creation-of-spam-transactions/7172)

<div class="topic-metadata">

**Author:** [@svimes](https://forum.fuel.network/u/svimes)\
**Replies:** 3\
**Last updated:** [December 14, 2024, 7:53pm UTC](https://forum.fuel.network/t/proof-of-work-predicate-to-limit-the-creation-of-spam-transactions/7172 "2024-12-14T19:53:06Z")

</div>

Proof of work gated transactions Purpose of this post I want to see whether or not the community would be interested in something like this. If so, Charthouse Labs will post a more complete RFC with a proper spec. Backg…

---

## [Is this the right way to create abstract contract for inheritiance?](https://forum.fuel.network/t/is-this-the-right-way-to-create-abstract-contract-for-inheritiance/7350)

<div class="topic-metadata">

**Author:** [@eesheng](https://forum.fuel.network/u/eesheng)\
**Replies:** 0\
**Last updated:** [December 13, 2024, 9:19am UTC](https://forum.fuel.network/t/is-this-the-right-way-to-create-abstract-contract-for-inheritiance/7350 "2024-12-13T09:19:10Z")

</div>

In Sway, you can define an abstract contract using an ABI and then implement that ABI in another contract. Here’s how you can create two contracts, A and B, where A is abstract and B inherits from A and overrides a funct…

---

## [If functions outside of the implementation block are private. What's the point of having a public function that is outside of ABI block?](https://forum.fuel.network/t/if-functions-outside-of-the-implementation-block-are-private-whats-the-point-of-having-a-public-function-that-is-outside-of-abi-block/7182)

<div class="topic-metadata">

**Author:** [@eesheng](https://forum.fuel.network/u/eesheng)\
**Replies:** 2\
**Last updated:** [December 12, 2024, 9:27am UTC](https://forum.fuel.network/t/if-functions-outside-of-the-implementation-block-are-private-whats-the-point-of-having-a-public-function-that-is-outside-of-abi-block/7182 "2024-12-12T09:27:01Z")

</div>

The ABI is for external calls only therefore you cannot define a method in the ABI and call it in the same contract. If you want to define a function for a contract, but keep it private so that only your contract can cal…

---

## [Understanding HTLC Integration for Cross-Chain Swaps on Fuel](https://forum.fuel.network/t/understanding-htlc-integration-for-cross-chain-swaps-on-fuel/6731)

<div class="topic-metadata">

**Author:** [@nerses](https://forum.fuel.network/u/nerses)\
**Replies:** 1\
**Last updated:** [December 11, 2024, 9:11pm UTC](https://forum.fuel.network/t/understanding-htlc-integration-for-cross-chain-swaps-on-fuel/6731 "2024-12-11T21:11:44Z")

</div>

I’m looking to understand how the Fuel network has integrated HTLCs (Hashed TimeLock Contracts) as a transaction mechanism and how they will be used for cross-chain swaps on Fuel. Are there any docs or GitHub repositorie…

---

## [Multiple SRC20 transfers in single transaction](https://forum.fuel.network/t/multiple-src20-transfers-in-single-transaction/7183)

<div class="topic-metadata">

**Author:** [@partylikeits1983](https://forum.fuel.network/u/partylikeits1983)\
**Replies:** 5\
**Last updated:** [December 11, 2024, 5:56pm UTC](https://forum.fuel.network/t/multiple-src20-transfers-in-single-transaction/7183 "2024-12-11T17:56:13Z")

</div>

In the Fuel VM it is not possible to send a SRC20 token to a contract, and then have the contract send the SRC20 token back to you in a single transaction. The following transfer is not possible in the Fuel VM: A =\> B …

---

## [Failed to compile contracts without error logs](https://forum.fuel.network/t/failed-to-compile-contracts-without-error-logs/7259)

<div class="topic-metadata">

**Author:** [@eesheng](https://forum.fuel.network/u/eesheng)\
**Replies:** 8\
**Last updated:** [December 11, 2024, 3:47am UTC](https://forum.fuel.network/t/failed-to-compile-contracts-without-error-logs/7259 "2024-12-11T03:47:25Z")

</div>

forc build return error without showing any errors, any ideas? error: Could not generate the entry method. See errors above for more details. \_\_\_\_ Aborting due to 1 error. error: Failed to compile contracts Fuelup s…

---

## [How to use the contract to mint NFTS](https://forum.fuel.network/t/how-to-use-the-contract-to-mint-nfts/7132)

<div class="topic-metadata">

**Author:** [@sho-shoaib](https://forum.fuel.network/u/sho-shoaib)\
**Replies:** 7\
**Last updated:** [December 10, 2024, 6:57pm UTC](https://forum.fuel.network/t/how-to-use-the-contract-to-mint-nfts/7132 "2024-12-10T18:57:48Z")

</div>

Hey Guys! I am using the NFT contract at https://github.com/FuelLabs/sway-applications/blob/master/NFT/NFT-contract/src/main.sw in my dapp which is used to mint NFTs. I am not able to understand how I should call the min…

---

## [Contract\_id relation with Asset\_id](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683)

<div class="topic-metadata">

**Author:** [@DevilAsap](https://forum.fuel.network/u/DevilAsap)\
**Replies:** 9\
**Last updated:** [December 10, 2024, 5:20am UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683 "2024-12-10T05:20:13Z")

</div>

If I have the contract\_id of the contract that minted a particular asset (associated with an Asset ID), how can I verify whether that specific contract\_id minted the given Asset ID? This issue could be resolved if there…

---

## [How to get assetid from a single SRC20 contract without knowing the subid?](https://forum.fuel.network/t/how-to-get-assetid-from-a-single-src20-contract-without-knowing-the-subid/7180)

<div class="topic-metadata">

**Author:** [@eesheng](https://forum.fuel.network/u/eesheng)\
**Replies:** 2\
**Last updated:** [December 9, 2024, 7:21am UTC](https://forum.fuel.network/t/how-to-get-assetid-from-a-single-src20-contract-without-knowing-the-subid/7180 "2024-12-09T07:21:30Z")

</div>

How do we get an assetId from a different contract that uses a particular SRC20? Contract A has token A and B. How do I get token A or token B? Similar to IERC20(tokena).balanceOf(ContractA). Do we need to know their s…

---

## [Recover ETH address from a signature](https://forum.fuel.network/t/recover-eth-address-from-a-signature/7170)

<div class="topic-metadata">

**Author:** [@etherhood](https://forum.fuel.network/u/etherhood)\
**Replies:** 2\
**Last updated:** [December 5, 2024, 1:55pm UTC](https://forum.fuel.network/t/recover-eth-address-from-a-signature/7170 "2024-12-05T13:55:19Z")

</div>

Is there an example where we extract eth address from a signature in sway?

---

## [Who call the functions in sway unit testing?](https://forum.fuel.network/t/who-call-the-functions-in-sway-unit-testing/7163)

<div class="topic-metadata">

**Author:** [@upon](https://forum.fuel.network/u/upon)\
**Replies:** 2\
**Last updated:** [December 4, 2024, 5:05am UTC](https://forum.fuel.network/t/who-call-the-functions-in-sway-unit-testing/7163 "2024-12-04T05:05:46Z")

</div>

I am writing a contract’s unit test #\[test\] fn test\_foo(){ let caller = abi(Mycontract,CONTRACT\_ID); caller.foo() } In function foo, I add a check as: require(msg\_sender().unwrap()==Idenfity::Address(Address::…

[Next page](https://forum.fuel.network/c/sway/5.md?page=1)
