Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/docs/basics/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To write CashScript smart contracts locally you use a code editor. For the best
:::

:::tip
To set up your CashScript developer environment, see the [Syntax Highlighting](/docs/guides/syntax-highlighting) guide.
To set up your CashScript developer environment, see the [Syntax Highlighting](/docs/language/syntax-highlighting) guide.
:::

### Installing the CashScript compiler
Expand Down
2 changes: 1 addition & 1 deletion website/docs/guides/adversarial.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ If DEXes don't cleverly aggregate their prices across blocks, then it can be eco
Because having a more advantageous (older) price state or ratio might be very profitable, it is worth it for the adversarial actor to pay the high fee "miner bribe" to attempt this double spend transaction.

:::tip
We list some possible mitigations which smart contract systems can implement in the section on ['Avoiding MEV'](#avoiding-mev)
We list some possible mitigations which smart contract systems can implement in the section on ['Avoiding MEV'](#mev-avoidance-strategies)
:::


Expand Down
6 changes: 3 additions & 3 deletions website/docs/guides/cashtokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ While CashTokens might seem overwhelming at first, realize that in contracts you

and their equivalent for outputs:

- **`bytes tx.outputs[i].tokenCategory`** - `tokenCategory` + `tokenCapability` of a specific output. (see [below](#1-tokencategory-contains-the-nft-capability)).
- **`bytes tx.outputs[i].tokenCategory`** - `tokenCategory` + `tokenCapability` of a specific output. (see [below](#tokencategory-contains-the-nft-capability)).
- **`bytes tx.outputs[i].nftCommitment`** - NFT commitment data of a specific output
- **`int tx.outputs[i].tokenAmount`** - Amount of fungible tokens of a specific output.

Expand All @@ -70,7 +70,7 @@ The [Jedex demo](https://github.com/bitjson/jedex) also introduces very advanced

Below we'll create a short list of the use cases which will be the most important to know about:

- **Covenant tracking tokens** - this is what enables unique authentication of contract deployments
- **Covenant tracking tokens** - this is what enables unique authentication of contract deployments
- **Commitment-based state management** - this is what `mutable` nfts are extremely useful for
- **Depository covenants/token pools** - which we would call token sidecars
- **Role tokens** - these are authentication tokens for admins
Expand Down Expand Up @@ -171,7 +171,7 @@ const contract = new Contract(artifact, [reverseHex(tokenId)], { provider })
Most end-user CashTokens wallets expect CashTokens UTXOs to only hold a tiny amount of BCH like 1000 sats. Deviating from the expectation might cause unforeseen problems with user's wallets.

:::tip
You can hard code in your contract that any user token output should have exactly `1000` sats, this avoids possible complicating freedom during transaction building.
You can hard code in your contract that any user token output should have exactly `1000` sats, this avoids possible complicating freedom during transaction building.
:::

However when constructing a transaction with user owned UTXOs, you should always make sure to check whether you handle the edge case of users with combined BCH + CashTokens UTXOs correctly in change output handling both for BCH and the tokens.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/guides/covenants.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,6 @@ With contracts holding minting NFTs, all outputs need to be carefully controlled
## Conclusion
We have discussed the main uses for covenants as they exist on Bitcoin Cash today. We've seen how we can achieve different use cases by combining transaction output restrictions to `P2SH` and `P2PKH` outputs. We also touched on more advanced subjects such as keeping local state in NFTs. Covenants and CashTokens are the **main differentiating factor** for BCH smart contracts when compared to BTC, while keeping the same **efficient, atomic verification**.

Keeping local state in NFTs and issuing NFTs as receipts are two strategies which can be used to create much more sophisticated decentralized applications. You can read more of these advanced CashTokens use cases in our [dedicated guide](/docs/guides/cashtokens#cashtokens-usecases)!
Keeping local state in NFTs and issuing NFTs as receipts are two strategies which can be used to create much more sophisticated decentralized applications. You can read more of these advanced CashTokens use cases in our [dedicated guide](/docs/guides/cashtokens#cashtokens-use-cases)!

[bitcoin-covenants]: https://fc16.ifca.ai/bitcoin/papers/MES16.pdf
10 changes: 10 additions & 0 deletions website/docs/language/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ See the following table for information on which types can be cast to other whic
| sig | bytes | bytes |
| datasig | bytes | bytes |

:::caution
Casting from `int` to `bool` does not currently change the value of the integer. This can have unexpected consequences in boolean comparisons.

```solidity
if (bool(7)) { ...} // This works as expected
if (bool(7) == true) { ... } // This does not work as expected
```

:::

### Int to Byte Casting

When casting integer types to bytes of a certain size, the integer value is padded with zeros, e.g. `bytes4(0) == 0x00000000`. It is also possible to pad with a variable number of zeros by passing in a `size` parameter, which indicates the size of the output, e.g. `bytes(0, 4 - 2) == 0x0000`.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/releases/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ CashScript used to be very tightly coupled with BITBOX. This proved to be proble
- :boom: Remove `Sig` alias for `SignatureTemplate` that was deprecated in v0.4.1.
- :boom: **BREAKING**: Refactor contract instantiation flow
- A contract is now instantiated by providing a compiled artifact, constructor arguments and an optional network provider.
- Anyone can implement the NetworkProvider interface to create a custom provider. The CashScript SDK offers three providers out of the box: one based on electrum-cash (default), one based on FullStack.cash' infrastructure, and one based on BITBOX. See the [NetworkProvider docs](/docs/sdk/instantiation#networkprovider) for details.
- Anyone can implement the NetworkProvider interface to create a custom provider. The CashScript SDK offers three providers out of the box: one based on electrum-cash (default), one based on FullStack.cash' infrastructure, and one based on BITBOX. See the [NetworkProvider docs](/docs/sdk/network-provider) for details.
- See the [migration notes](/docs/releases/migration-notes#v04-to-v05) for details on migrating from the old contract instantiation flow.
- :boom: **BREAKING**: Remove the artifacts `'networks'` field and `.deployed()` functionality, This proved to be confusing and is better suited to be handled outside of the CashScript SDK.
- :boom: **BREAKING**: `.send()` now returns a libauth Transaction instead of a BITBOX Transaction object. Alternatively a `raw` flag can be passed into the function to return a raw hex string.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/sdk/instantiation.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ contract.address: string
A contract's regular address (without token-support) can be retrieved through the `address` member field.

:::note
Wallets will not allow you to send CashTokens to this address. For that you must use the [tokenAddress](#tokenAddress) below. Wallets which have not upgraded might not recognize this new address type.
Wallets will not allow you to send CashTokens to this address. For that you must use the [tokenAddress](#tokenaddress) below. Wallets which have not upgraded might not recognize this new address type.
:::

#### Example
Expand Down
8 changes: 4 additions & 4 deletions website/docs/sdk/transaction-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ import { aliceTemplate, aliceAddress, bobAddress, contract, provider } from './s

const contractUtxos = await contract.getUtxos();
const aliceUtxos = await provider.getUtxos(aliceAddress);
const maximumFeeSatoshis = 1000n;

const txDetails = await new TransactionBuilder({ provider })
const txDetails = await new TransactionBuilder({ provider, maximumFeeSatoshis })
.addInput(contractUtxos[0], contract.unlock.spend(aliceTemplate, 1000n))
.addInput(aliceUtxos[0], aliceTemplate.unlockP2PKH())
.addOutput({ to: bobAddress, amount: 100_000n })
.addOpReturnOutput(['0x6d02', 'Hello World!'])
.setMaxFee(2000n)
.send()
```

Expand All @@ -226,13 +226,13 @@ import { aliceTemplate, aliceAddress, bobAddress, contract, provider } from './s

const contractUtxos = await contract.getUtxos();
const aliceUtxos = await provider.getUtxos(aliceAddress);
const maximumFeeSatoshis = 1000n;

const txHex = new TransactionBuilder({ provider })
const txHex = new TransactionBuilder({ provider, maximumFeeSatoshis })
.addInput(contractUtxos[0], contract.unlock.spend(aliceTemplate, 1000n))
.addInput(aliceUtxos[0], aliceTemplate.unlockP2PKH())
.addOutput({ to: bobAddress, amount: 100_000n })
.addOpReturnOutput(['0x6d02', 'Hello World!'])
.setMaxFee(2000n)
.build()
```

Expand Down
24 changes: 15 additions & 9 deletions website/docusaurus.config.js → website/docusaurus.config.ts
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
import { themes as prismThemes } from 'prism-react-renderer';
import type { Config } from '@docusaurus/types';
import type { Options as ClassicPresetOptions } from '@docusaurus/preset-classic';

const config: Config = {
title: 'CashScript',
tagline: 'Smart contracts for Bitcoin Cash',
url: 'https://cashscript.org',
Expand All @@ -8,8 +12,8 @@ module.exports = {
projectName: 'cashscript',
themeConfig: {
prism: {
theme: require('prism-react-renderer').themes.nightOwlLight,
darkTheme: require('prism-react-renderer').themes.nightOwl,
theme: prismThemes.nightOwlLight,
darkTheme: prismThemes.nightOwl,
additionalLanguages: ['solidity', 'antlr4'],
},
image: 'img/logo.svg',
Expand All @@ -19,7 +23,7 @@ module.exports = {
src: 'img/logo.svg',
},
items: [
{to: '/docs/basics/about', label: 'Docs', position: 'right'},
{ to: '/docs/basics/about', label: 'Docs', position: 'right' },
{
href: 'https://playground.cashscript.org',
label: 'Playground',
Expand Down Expand Up @@ -99,15 +103,15 @@ module.exports = {
},
presets: [
[
'@docusaurus/preset-classic',
'classic',
{
theme: {
customCss: require.resolve('./src/css/custom.css'),
customCss: './src/css/custom.css',
},
docs: {
sidebarPath: './sidebars.js',
sidebarPath: './sidebars.ts',
},
},
} as ClassicPresetOptions,
],
],
plugins: [
Expand All @@ -116,7 +120,7 @@ module.exports = {
{
fromExtensions: ['html'],
redirects: [
{ from: ['/docs', '/docs/about', '/docs/basics'], to: '/docs/basics/about'},
{ from: ['/docs', '/docs/about', '/docs/basics'], to: '/docs/basics/about' },
{ from: '/docs/language', to: '/docs/language/contracts' },
{ from: '/docs/sdk', to: '/docs/sdk/instantiation' },
{ from: '/docs/sdk/transactions-advanced', to: '/docs/sdk/transaction-builder' },
Expand All @@ -130,3 +134,5 @@ module.exports = {
['@branchup/docusaurus-plugin-simple-analytics', {}],
],
};

export default config;
18 changes: 11 additions & 7 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
},
"dependencies": {
"@branchup/docusaurus-plugin-simple-analytics": "^1.1.0",
"@docusaurus/core": "^2.4.1",
"@docusaurus/plugin-client-redirects": "^2.4.1",
"@docusaurus/preset-classic": "^2.4.1",
"classnames": "^2.3.2",
"prism-react-renderer": "^2.0.4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"@docusaurus/core": "^3.9.2",
"@docusaurus/plugin-client-redirects": "^3.9.2",
"@docusaurus/preset-classic": "^3.9.2",
"classnames": "^2.5.1",
"prism-react-renderer": "^2.4.1",
"react": "^19.2.3",
"react-dom": "^19.2.3"
},
"devDependencies": {
"@docusaurus/tsconfig": "^3.9.2",
"typescript": "^5.9.2"
},
"browserslist": {
"production": [
Expand Down
6 changes: 5 additions & 1 deletion website/sidebars.js → website/sidebars.ts
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs';

const sidebars: SidebarsConfig = {
docs: [
{
type: 'category',
Expand Down Expand Up @@ -76,3 +78,5 @@ module.exports = {
'showcase',
],
};

export default sidebars;
8 changes: 8 additions & 0 deletions website/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

/* Slightly smaller code font */
--ifm-code-font-size: 95%;

--docsearch-muted-color: rgba(0, 0, 0, 0.5) !important;
}

.navbar--dark {
Expand Down Expand Up @@ -79,6 +81,8 @@ html[data-theme="dark"] {
--ifm-heading-color: #ffffff;

--ifm-alert-background-color: #474748;

--docsearch-muted-color: rgba(255, 255, 255, 0.5) !important;
}

/* NOTE admonitions should be light grey (instead of secondary colour) */
Expand All @@ -98,3 +102,7 @@ html[data-theme="dark"] {
h5 {
color: var(--ifm-alert-color) !important;
}

.DocSearch-Search-Icon {
color: var(--ifm-heading-color) !important;
}
21 changes: 13 additions & 8 deletions website/src/pages/index.js → website/src/pages/index.tsx
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import styles from './index.module.css';

const features = [
type FeatureItem = {
title: string;
description: React.ReactNode;
imageUrl?: string;
};

const features: FeatureItem[] = [
{
title: 'TypeScript SDK',
description: (
Expand Down Expand Up @@ -47,8 +53,8 @@ const features = [
},
];

function Feature({imageUrl, title, description}) {
const imgUrl = useBaseUrl(imageUrl);
function Feature({ imageUrl, title, description }: FeatureItem) {
const imgUrl = imageUrl ? useBaseUrl(imageUrl) : undefined;
return (
<div className={classnames('col col--6', styles.feature)}>
{imgUrl && (
Expand All @@ -62,14 +68,13 @@ function Feature({imageUrl, title, description}) {
);
}

function Home() {
function Home(): React.ReactNode {
const context = useDocusaurusContext();
const {siteConfig = {}} = context;
const { siteConfig } = context;
return (
<Layout
title={`${siteConfig.title}: ${siteConfig.tagline}`}
description='A high-level smart contract language for Bitcoin Cash. Write complex smart contracts with a straightforward syntax and integrate them into your JavaScript applications.'
keywords={['cashscript','smart contracts','bitcoin cash', 'compiler', 'sdk', 'programming language']}>
description='A high-level smart contract language for Bitcoin Cash. Write complex smart contracts with a straightforward syntax and integrate them into your JavaScript applications.'>
<header className={classnames('hero', styles.banner)}>
<div className='container'>
<div className='row'>
Expand Down Expand Up @@ -99,7 +104,7 @@ function Home() {
</div>
</header>
<main>
{features && features.length && (
{features && features.length > 0 && (
<section className={styles.features}>
<div className='container margin-vert--md'>
<div className='row'>
Expand Down
34 changes: 34 additions & 0 deletions website/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"extends": "@docusaurus/tsconfig",
"compilerOptions": {
"target": "es2020",
"lib": [
"dom",
"dom.iterable",
"esnext",
"es2021"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": ".",
},
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.jsx",
],
"exclude": [
"**/node_modules"
]
}
Loading