deploy

Will deploy a compiled smart contract to the blockchain with the provided input parameters. The GAS cost for deploying the contract will be calculated by the provider, and displayed to the user upon tx acceptance or rejection.

Input Arguments

ParameterDescription

network?: string

Network to submit this request to. If omitted, will default to network the wallet is currently set to

name: string

The name of the contract to be deployed

version: string

The version of the contract to be deployed

author: string

The author of the contract to be deployed

email: string

The email of the contract to be deployed

description: string

The description of the contract to be deployed

needsStorage?: boolean

Whether or not the contract will use storage

dynamicInvoke?: boolean

Whether or not the contract will be performing dynamic invocations of other smart contracts

isPayable?: boolean

Whether or not the contract will be able to accept native assets

parameterList: string

The list of input argument types for the Main function on the contract. https://docs.neo.org/en-us/sc/Parameter.html

returnType: string

The list of output returnType argument types. https://docs.neo.org/en-us/sc/Parameter.html

code: string

The hex of the compiled smart contract avm

netowrkFee: number

The network fee to execute the transaction, in addition to the deploy fee which will be added automatically

broadcastOverride?: boolean

In the case that the dApp would like to be responsible for broadcasting the signed transaction rather than the wallet provider

Success Response

In the case where the "broadcastOverride" input argument is not set, or set to false.

ParameterDescription

txid: string

The transaction ID of the invocation

nodeURL: string

The node which the transaction was broadcast to. Returned if transaction is broadcast by wallet

In the case where the "broadcastOverride" input argument is set to True.

ParameterDescription

txid: string

The transaction ID of the invocation

signedTx: string

The serialized signed transaction. Only returned if the broadcastOverride input argument was set to True

Error Response

ParameterDescription

type: string

The type of error which has occured

description: string

A description of the error which has occured

data: string

Any raw data associated with the error

Example

Request

neoline.deploy({
  network: 'TestNet',
  name: 'Hello world!',
  version: 'v1.0.0',
  author: 'NEOLine',
  email: 'info@neoline.network',
  description: 'My first contract.',
  needsStorage: true,
  dynamicInvoke: false,
  isPayable: false,
  parameterList: '0710',
  returnType: '05',
  code: '53c56b0d57616b652075702c204e454f21680f4e656f2e52756e74696d652e4c6f6761006c7566',
  networkFee: '0.001'
})
.then(({txid, nodeURL}: InvokeOutput) => {
  console.log('Deploy transaction success!');
  console.log('Transaction ID: ' + txid);
  console.log('RPC node URL: ' + nodeURL);
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case UNKNOWN_ERROR:
        console.log(description);
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

Response

{
  txid: '629b5f35e42aa6b65cd97ae3a95f89547596f4e2783c8778428c7f32df07918e',
  nodeUrl: 'https://testnet.api.neoline.io'
};  

最后更新于