A signer for VeChain, adding specific methods for VeChain to the ethers signer

@NOTE: Su support completely our providers (that already support ethers provider format) We use our supported providers instead of ethers providers

interface VeChainSigner {
    call: ((transactionToEvaluate: TransactionRequestInput, revision?: string) => Promise<string>);
    connect: ((provider: AvailableVeChainProviders) => this);
    estimateGas: ((transactionToEstimate: TransactionRequestInput) => Promise<number>);
    getAddress: (() => Promise<string>);
    getNonce: ((blockTag?: string) => Promise<string>);
    populateCall: ((transactionToPopulate: TransactionRequestInput) => Promise<TransactionRequestInput>);
    populateTransaction: ((transactionToPopulate: TransactionRequestInput) => Promise<TransactionBody>);
    provider?: AvailableVeChainProviders;
    resolveName: ((vnsName: string) => Promise<string>);
    sendTransaction: ((transactionToSend: TransactionRequestInput) => Promise<string>);
    signMessage: ((message: string | Uint8Array) => Promise<string>);
    signTransaction: ((transactionToSign: TransactionRequestInput) => Promise<string>);
    signTypedData: ((domain: TypedDataDomain, types: Record<string, TypedDataParameter[]>, message: Record<string, unknown>, primaryType?: string, options?: SignTypedDataOptions) => Promise<string>);
}

Implemented by

Properties

call: ((transactionToEvaluate: TransactionRequestInput, revision?: string) => Promise<string>)

Evaluates the //tx// by running it against the current Blockchain state. This cannot change state and has no cost, as it is effectively simulating execution.

This can be used to have the Blockchain perform computations based on its state (e.g. running a Contract's getters) or to simulate the effect of a transaction before actually performing an operation.

Type declaration

    • (transactionToEvaluate, revision?): Promise<string>
    • Parameters

      • transactionToEvaluate: TransactionRequestInput

        The transaction to evaluate

      • Optionalrevision: string

        The revision to evaluate the transaction against

      Returns Promise<string>

      the result of the evaluation

connect: ((provider: AvailableVeChainProviders) => this)

Returns a new instance of this Signer connected to //provider// or detached from any Provider if undefined.

Type declaration

    • (provider): this
    • Parameters

      Returns this

      a new instance of this Signer connected to //provider// or detached

estimateGas: ((transactionToEstimate: TransactionRequestInput) => Promise<number>)

Estimates the required gas required to execute //tx// on the Blockchain. This will be the expected amount a transaction will require to successfully run all the necessary computations and store the needed state that the transaction intends.

Type declaration

    • (transactionToEstimate): Promise<number>
    • Parameters

      Returns Promise<number>

      the total estimated gas required

getAddress: (() => Promise<string>)

Get the address of the Signer.

Type declaration

    • (): Promise<string>
    • Returns Promise<string>

      the address of the signer

getNonce: ((blockTag?: string) => Promise<string>)

Gets the next nonce required for this Signer to send a transaction.

Type declaration

    • (blockTag?): Promise<string>
    • Parameters

      • OptionalblockTag: string

        The blocktag to base the transaction count on, keep in mind many nodes do not honour this value and silently ignore it [default: "latest"]

        @NOTE: This method generates a random number as nonce. It is because the nonce in VeChain is a 6-byte number.

      Returns Promise<string>

populateCall: ((transactionToPopulate: TransactionRequestInput) => Promise<TransactionRequestInput>)

Prepares a TransactionRequestInput for calling:

  • resolves to and from addresses
  • if from is specified, check that it matches this Signer

@note: Here the base support of multi-clause transaction is added. So, if clauses are provided in the transaction, it will be used as it is. Otherwise, standard transaction will be prepared.

Type declaration

populateTransaction: ((transactionToPopulate: TransactionRequestInput) => Promise<TransactionBody>)

Prepares a TransactionRequestInput for sending to the network by populating any missing properties:

  • resolves to and from addresses
  • if from is specified , check that it matches this Signer
  • populates nonce via signer.getNonce("pending")
  • populates gas parameters via signer.estimateGas(tx)
  • ... and other necessary properties

Type declaration

    • (transactionToPopulate): Promise<TransactionBody>
    • Parameters

      Returns Promise<TransactionBody>

      the prepared transaction

The provider attached to this Signer (if any).

resolveName: ((vnsName: string) => Promise<string>)

Resolves an VNS Name to an address.

sendTransaction: ((transactionToSend: TransactionRequestInput) => Promise<string>)

Sends %%transactionToSend%% to the Network. The signer.populateTransaction(transactionToSend) is called first to ensure all necessary properties for the transaction to be valid have been populated first.

Type declaration

    • (transactionToSend): Promise<string>
    • Parameters

      Returns Promise<string>

      The transaction response

signMessage: ((message: string | Uint8Array) => Promise<string>)

Signs an [[link-eip-191]] prefixed a personal message.

If the %%message%% is a string, it is signed as UTF-8 encoded bytes. It is not interpreted as a [[BytesLike]]; so the string "0x1234" is signed as six characters, not two bytes.

To sign that example as two bytes, the Uint8Array should be used (i.e. new Uint8Array([ 0x12, 0x34 ])).

signTransaction: ((transactionToSign: TransactionRequestInput) => Promise<string>)

Signs %%transactionToSign%%, returning the fully signed transaction. This does not populate any additional properties within the transaction.

Type declaration

    • (transactionToSign): Promise<string>
    • Parameters

      Returns Promise<string>

      The fully signed transaction

signTypedData: ((domain: TypedDataDomain, types: Record<string, TypedDataParameter[]>, message: Record<string, unknown>, primaryType?: string, options?: SignTypedDataOptions) => Promise<string>)

Signs the [[link-eip-712]] typed data.