# Can we deploy predicates on chain?

**URL:** <https://forum.fuel.network/t/can-we-deploy-predicates-on-chain/1649>\
**Category:** Sway\
**Created:** [January 25, 2023, 12:17am UTC](https://forum.fuel.network/t/can-we-deploy-predicates-on-chain/1649 "2023-01-25T00:17:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![felix200912](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/felix200912/32/1013_2.png) [@felix200912](https://forum.fuel.network/u/felix200912)\
**Post date:** [January 25, 2023, 12:17am UTC](https://forum.fuel.network/t/can-we-deploy-predicates-on-chain/1649/1 "2023-01-25T00:17:55Z")

</div>

Can we deploy predicates on-chain or do we need to load each time we run it, like a script with an address and returning boolean?

---

<div class="post-metadata">

**Author:** ![mohammadfawaz](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@mohammadfawaz](https://forum.fuel.network/u/mohammadfawaz)\
**Post date:** [January 26, 2023, 9:15am UTC](https://forum.fuel.network/t/can-we-deploy-predicates-on-chain/1649/2 "2023-01-26T09:15:45Z")

</div>

The following article describes predicates really well: [The Power of Predicates: A Purpose-Built Mechanism for Transaction Authorization | by Ryan Sproule | Blockchain Capital Blog | Jan, 2023 | Medium](https://medium.com/blockchain-capital-blog/the-power-of-predicates-73f874cfa9a5)

To quote the article:  
“Unlike contract code, predicate code is never “deployed” to the chain. To create a predicate, someone simply writes the code for the predicate and then uses a compiler to generate a code hash, there is no interaction with the chain. Since the hash is both deterministic and collision-resistant, the coins locked in this address can only ever be spent if the predicate conditions are met. To spend a predicate, someone would provide the predicate bytecode (which must match the hash/address that the coins are behind) and a transaction that has the predicate resolve to true.”

---

<div class="post-metadata">

**Author:** ![Daniel-Verilog](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/daniel-verilog/32/705_2.png) [@Daniel-Verilog](https://forum.fuel.network/u/Daniel-Verilog)\
**Post date:** [January 27, 2023, 2:20am UTC](https://forum.fuel.network/t/can-we-deploy-predicates-on-chain/1649/3 "2023-01-27T02:20:55Z")

</div>

thanks for your reply, that is a very good answer.

btw, I agree with your understanding and I personally feel predicate in sway is very similar to bitcoinscript.

However, in sway programming language [github.io](http://github.io), there is a paragraph:

> A Sway program itself has a type: it is either a _contract_, a _predicate_, a _script_, or a _library_. The first three of these things are all deployable to the blockchain. A _library_ is simply a project designed for code reuse and is never directly deployed to the chain.

seems on the sway book, it mentions predicate is deployable.

checkout here:  
[https://fuellabs.github.io/sway/v0.33.1/book/sway-program-types/index.html](https://fuellabs.github.io/sway/v0.33.1/book/sway-program-types/index.html)

---

<div class="post-metadata">

**Author:** ![mohammadfawaz](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@mohammadfawaz](https://forum.fuel.network/u/mohammadfawaz)\
**Post date:** [January 27, 2023, 9:49am UTC](https://forum.fuel.network/t/can-we-deploy-predicates-on-chain/1649/4 "2023-01-27T09:49:35Z")

</div>

Oh yes thank you for pointing this out. Indeed, this is a misleading sentence. We should change it, so I opened this issue: [Clarify how different program types are used · Issue #3908 · FuelLabs/sway · GitHub](https://github.com/FuelLabs/sway/issues/3908)

---

<div class="post-metadata">

**Author:** ![Daniel-Verilog](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/daniel-verilog/32/705_2.png) [@Daniel-Verilog](https://forum.fuel.network/u/Daniel-Verilog)\
**Post date:** [February 3, 2023, 9:36pm UTC](https://forum.fuel.network/t/can-we-deploy-predicates-on-chain/1649/5 "2023-02-03T21:36:16Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/1X/7d5e967b4f0506f24d46676bc9dc37670961cfcc.png)  
also checkout here:  
[https://fuellabs.github.io/fuel-docs/master/developer-quickstart.html](https://fuellabs.github.io/fuel-docs/master/developer-quickstart.html)

i am a bit confused here lol

---

<div class="post-metadata">

**Author:** ![ControlCplusControlV](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/controlcpluscontrolv/32/999_2.png) [@ControlCplusControlV](https://forum.fuel.network/u/ControlCplusControlV)\
**Post date:** [February 6, 2023, 1:24am UTC](https://forum.fuel.network/t/can-we-deploy-predicates-on-chain/1649/6 "2023-02-06T01:24:32Z")

</div>

Yeah fixing this now, predicates can’t be deployed, only supplied as inputs. PR for correction is open [here](https://github.com/FuelLabs/fuel-docs/pull/72) 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [February 26, 2023, 9:25pm UTC](https://forum.fuel.network/t/can-we-deploy-predicates-on-chain/1649/7 "2023-02-26T21:25:25Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
