Skip to content

useCompileContract

Primitive for compiling Sophia smart contract source code.

Import

typescript
import { useCompileContract } from '@growae/reactive-solid'

Usage

tsx
import { useCompileContract } from '@growae/reactive-solid'

function CompileForm() {
  const compileContract = useCompileContract()

  return (
    <div>
      <button
        onClick={() =>
          compileContract.mutate({ sourceCode, onCompiler: compiler })
        }
        disabled={compileContract.isPending}
      >
        Compile
      </button>
      <Show when={compileContract.data}>
        <p>Bytecode: {compileContract.data?.bytecode}</p>
      </Show>
    </div>
  )
}

Parameters

See compileContract Parameters.

Key parameters:

ParameterTypeDefaultDescription
sourceCodestringRequired. Sophia source code to compile.
fileSystemRecord<string, string>Optional. Map of included file paths to their contents.
onCompilerCompilerBaseRequired. Compiler instance to use.

Action