# Function

Static Public Summary
public | async castProxyVote(request: *, svConfig: *): * |
public | checkBallotHashBSpec(rawBallotSpecString: *, expectedSpecHash: *): boolean Verify a BallotSpec's hash |
public | checkBallotHashGBallot(ballotObject: *): * |
public | async checkIfAddressIsEditor(objectPattern: {"svNetwork": *}, objectPattern1: {"userAddress": *, "democHash": *}): * |
public | cleanEthHex(hex: string): string This will take an Ethereum hex string (or a normal hex string) and output a normal hex string (no '0x' header) or throw an error on a bad hex string. |
public | createEd25519DelegationTransaction(svNetwork: *, dlgtRequest: *, pubKey: *, signature: *, privKey: *): to: string, value: number, gas: number, data: string Create a tx object for an ed25519 delegation |
public | ed25519DelegationIsValid(dlgtRequest: *, pubKey: *, signature: *): boolean Verify an ed25519 self-delegation |
public | ethAddrEq(addr1: string, addr2: string): bool This compares ethereum addresses (taking into account case, etc) |
public | ethSignHash(messageHash: *, privateKey: *): {messageHash: string, r: string, s: string, v: string} Sign a message such that it can be verified with `ecrecover`. |
public | ethVerifySig(messageHash: string, v, r, s: string[]): {verified: bool, address: EthAddress} Operates `ecrecover` over the provided signature |
public | genRange3VoteData(votesArray: array): string Prepares voteData for a Range3 ballot from an array of votes |
public | async getBackendAddress(objectPattern: {"index": *}): * |
public | async getBallotObjectFromIpfs(ballotSpecHash: *): * |
public | async getBallotObjectFromS3(archiveUrl: *, ballotSpecHash: *): * |
public | async getBallotSpec(archiveUrl: *, ballotSpecHash: *): * |
public | async getCommunityBallotPrice(objectPattern: {"payments": *}, democHash: *): * |
public | async getContractAddresses(objectPattern: {"svNetwork": *}): {"indexAddress": *, "backendAddress": *, "auxAddress": *, "lookupAddress": *, "resolverAddress": *, "communityAuctionAddress": *, "delegationAddress": *, "paymentsAddress": *} Takes in the svNetwork object and returns all relevant addresses |
public | async getCurrentGasPrice(): {"safeLow": *, "average": *, "fast": *, "fastest": *} |
public | async getDemocBallots(objectPattern: {"svNetwork": *, "democHash": *}): * |
public | async getDemocInfo(objectPattern: {"backend": *, "democHash": *}): * |
public | async getDemocNthBallot(objectPattern: {"svNetwork": *}, democBallotInfo: *): * |
public | getNetwork(networkId: *, chainId: *): * |
public | getSingularCleanAbi(requestedAbiName: *, methodName: *): * |
public | async getUnsafeEd25519Delegations(pubKey: *, svNetwork: *): * |
public | hashMsgRaw(data: *): * Like web3.eth.accounts.hashMessage without the envelope. |
public | hexToBase32(hex: string): string This will convert a hex string to Base32 in the bech32 format WITHOUT a checksum. |
public | hexToUint8Array(hex: string): Uint8Array Turn a hexstring (with or without prefix) to a Uint8Array |
public | async initializeSvLight(svConfig: *): {"svConfig": *, "web3": *, "resolver": *, "index": *, "backend": *, "aux": *, "payments": *} |
public | mkPacked(start: number, end: number, submissionBits: number): BN Creates a packed copy of start and end times with submissionBits |
public | mkSignedBallotForProxy(ballotId: string, sequence: number, voteData: string, extra: string, privateKey: string, opts: object): object Take the arguments and produce web3 data fitting the `submitProxyVote` method. |
public | mkSubmissionBits(toCombine: number[]): number This combines flags into a finished submissionBits. |
public | networkName(networkId: *): string |
public | prepareEd25519Delegation(address: *, nonce: *): Bytes32 Generate a packed Ed25519Delegation instruction for use with the smart contract or API |
public | async prepareWeb3BBVoteTx(txInfo: object, svNetwork: object): object Prepares a transaction for sending with the users web3 browser |
public | async resolveEnsAddress(objectPattern: {"resolver": *}, ensName: *): * |
public | stellarPkToHex(pubKey: *): * |
public | verifySignedBallotForProxy(proxyVote: ProxyVote, opts: *): {verified: bool, address: EthAddress} Verify a signed vote to be submitted via proxy as generated by `mkSignedBallotForProxy` |
public | async weiToCents(objectPattern: {"payments": *}, wei: *): * |

## Static Public

### public async castProxyVote(request: *, svConfig: *): * source

    import {castProxyVote} from 'sv-lib/src/ballotBox.ts'

#### Params:

Name | Type | Attribute | Description
request | * |  |
svConfig | * |  |

#### Return:

*

### public checkBallotHashBSpec(rawBallotSpecString: *, expectedSpecHash: *): boolean source

    import {checkBallotHashBSpec} from 'sv-lib/src/light.ts'

Verify a BallotSpec's hash

#### Params:

Name | Type | Attribute | Description
rawBallotSpecString | * |  | The raw string/bytes before JSON.parse
expectedSpecHash | * |  | The expected hash as Eth Hex

#### Return:

boolean | Whether the ballotSpec matched the expected hash

### public checkBallotHashGBallot(ballotObject: *): * source

    import {checkBallotHashGBallot} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
ballotObject | * |  |

#### Return:

*

### public async checkIfAddressIsEditor(objectPattern: {"svNetwork": *}, objectPattern1: {"userAddress": *, "democHash": *}): * source

    import {checkIfAddressIsEditor} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
objectPattern | {"svNetwork": *} | default: {"svNetwork":null} |
objectPattern1 | {"userAddress": *, "democHash": *} | default: {"userAddress":null,"democHash":null} |

#### Return:

*

### public cleanEthHex(hex: string): string source

    import {cleanEthHex} from 'sv-lib/src/utils.ts'

This will take an Ethereum hex string (or a normal hex string) and output a normal hex string (no '0x' header) or throw an error on a bad hex string.

#### Params:

Name | Type | Attribute | Description
hex | string |  |

#### Return:

string | the hex string.

### public createEd25519DelegationTransaction(svNetwork: *, dlgtRequest: *, pubKey: *, signature: *, privKey: *): to: string, value: number, gas: number, data: string source

    import {createEd25519DelegationTransaction} from 'sv-lib/src/light.ts'

Create a tx object for an ed25519 delegation

#### Params:

Name | Type | Attribute | Description
svNetwork | * |  |
dlgtRequest | * |  |
pubKey | * |  |
signature | * |  |
privKey | * |  |

#### Return:

to: string, value: number, gas: number, data: string

### public ed25519DelegationIsValid(dlgtRequest: *, pubKey: *, signature: *): boolean source

    import {ed25519DelegationIsValid} from 'sv-lib/src/light.ts'

Verify an ed25519 self-delegation

#### Params:

Name | Type | Attribute | Description
dlgtRequest | * |  | eth hex string of the dlgt request
pubKey | * |  | stellar pubkey
signature | * |  | 64 byte signature as eth hex

#### Return:

boolean

### public ethAddrEq(addr1: string, addr2: string): bool source

    import {ethAddrEq} from 'sv-lib/src/utils.ts'

This compares ethereum addresses (taking into account case, etc)

#### Params:

Name | Type | Attribute | Description
addr1 | string |  |
addr2 | string |  |

#### Return:

bool

### public ethSignHash(messageHash: *, privateKey: *): {messageHash: string, r: string, s: string, v: string} source

    import {ethSignHash} from 'sv-lib/src/crypto.ts'

Sign a message such that it can be verified with `ecrecover`. Similar to `web3.eth.accounts.sign` except that we sign the hash directly.

#### Params:

Name | Type | Attribute | Description
messageHash | * |  | Hash of a message, as returned by `web3.utils.soliditySha3` or similar.
privateKey | * |  | Privkey to sign with.

#### Return:

{messageHash: string, r: string, s: string, v: string}

### public ethVerifySig(messageHash: string, v, r, s: string[]): {verified: bool, address: EthAddress} source

    import {ethVerifySig} from 'sv-lib/src/crypto.ts'

Operates `ecrecover` over the provided signature

#### Params:

Name | Type | Attribute | Description
messageHash | string |  | This should be an Ethereum HexString
v, r, s | string[] | optional | Components for the secp256k1 signature

#### Return:

{verified: bool, address: EthAddress}

### public genRange3VoteData(votesArray: array): string source

    import {genRange3VoteData} from 'sv-lib/src/ballotBox.ts'

Prepares voteData for a Range3 ballot from an array of votes

#### Params:

Name | Type | Attribute | Description
votesArray | array |  | Takes an array of numbers which represent the votes to be transformed Format: [1, 2, -1]

#### Return:

string | Returns an eth hex string of the vote data

### public async getBackendAddress(objectPattern: {"index": *}): * source

    import {getBackendAddress} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
objectPattern | {"index": *} | default: {"index":null} |

#### Return:

*

### public async getBallotObjectFromIpfs(ballotSpecHash: *): * source

    import {getBallotObjectFromIpfs} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
ballotSpecHash | * |  |

#### Return:

*

### public async getBallotObjectFromS3(archiveUrl: *, ballotSpecHash: *): * source

    import {getBallotObjectFromS3} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
archiveUrl | * |  |
ballotSpecHash | * |  |

#### Return:

*

### public async getBallotSpec(archiveUrl: *, ballotSpecHash: *): * source

    import {getBallotSpec} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
archiveUrl | * |  |
ballotSpecHash | * |  |

#### Return:

*

### public async getCommunityBallotPrice(objectPattern: {"payments": *}, democHash: *): * source

    import {getCommunityBallotPrice} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
objectPattern | {"payments": *} | default: {"payments":null} |
democHash | * |  |

#### Return:

*

### public async getContractAddresses(objectPattern: {"svNetwork": *}): {"indexAddress": *, "backendAddress": *, "auxAddress": *, "lookupAddress": *, "resolverAddress": *, "communityAuctionAddress": *, "delegationAddress": *, "paymentsAddress": *} source

    import {getContractAddresses} from 'sv-lib/src/light.ts'

Takes in the svNetwork object and returns all relevant addresses

#### Params:

Name | Type | Attribute | Description
objectPattern | {"svNetwork": *} | default: {"svNetwork":null} |

#### Return:

{"indexAddress": *, "backendAddress": *, "auxAddress": *, "lookupAddress": *, "resolverAddress": *, "communityAuctionAddress": *, "delegationAddress": *, "paymentsAddress": *}

### public async getCurrentGasPrice(): {"safeLow": *, "average": *, "fast": *, "fastest": *} source

    import {getCurrentGasPrice} from 'sv-lib/src/light.ts'

#### Return:

{"safeLow": *, "average": *, "fast": *, "fastest": *}

### public async getDemocBallots(objectPattern: {"svNetwork": *, "democHash": *}): * source

    import {getDemocBallots} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
objectPattern | {"svNetwork": *, "democHash": *} | default: {"svNetwork":null,"democHash":null} |

#### Return:

*

### public async getDemocInfo(objectPattern: {"backend": *, "democHash": *}): * source

    import {getDemocInfo} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
objectPattern | {"backend": *, "democHash": *} | default: {"backend":null,"democHash":null} |

#### Return:

*

### public async getDemocNthBallot(objectPattern: {"svNetwork": *}, democBallotInfo: *): * source

    import {getDemocNthBallot} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
objectPattern | {"svNetwork": *} | default: {"svNetwork":null} |
democBallotInfo | * |  |

#### Return:

*

### public getNetwork(networkId: *, chainId: *): * source

    import {getNetwork} from 'sv-lib/src/const.ts'

#### Params:

Name | Type | Attribute | Description
networkId | * |  |
chainId | * |  |

#### Return:

*

### public getSingularCleanAbi(requestedAbiName: *, methodName: *): * source

    import {getSingularCleanAbi} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
requestedAbiName | * |  |
methodName | * |  |

#### Return:

*

### public async getUnsafeEd25519Delegations(pubKey: *, svNetwork: *): * source

    import {getUnsafeEd25519Delegations} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
pubKey | * |  |
svNetwork | * |  |

#### Return:

*

### public hashMsgRaw(data: *): * source

    import {hashMsgRaw} from 'sv-lib/src/crypto.ts'

Like web3.eth.accounts.hashMessage without the envelope.

#### Params:

Name | Type | Attribute | Description
data | * |  | A message to hash - if it is hex it'll be UTF8 decoded.

#### Return:

* | The hashed message (using keccak256)

### public hexToBase32(hex: string): string source

    import {hexToBase32} from 'sv-lib/src/utils.ts'

This will convert a hex string to Base32 in the bech32 format WITHOUT a checksum.

#### Params:

Name | Type | Attribute | Description
hex | string |  | The hex string to convert to Base32 - can be an EthHex or plain hex string.

#### Return:

string | The Base32 version of the hex string.

### public hexToUint8Array(hex: string): Uint8Array source

    import {hexToUint8Array} from 'sv-lib/src/utils.ts'

Turn a hexstring (with or without prefix) to a Uint8Array

#### Params:

Name | Type | Attribute | Description
hex | string |  |

#### Return:

Uint8Array

### public async initializeSvLight(svConfig: *): {"svConfig": *, "web3": *, "resolver": *, "index": *, "backend": *, "aux": *, "payments": *} source

    import {initializeSvLight} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
svConfig | * |  |

#### Return:

{"svConfig": *, "web3": *, "resolver": *, "index": *, "backend": *, "aux": *, "payments": *}

### public mkPacked(start: number, end: number, submissionBits: number): BN source

    import {mkPacked} from 'sv-lib/src/ballotBox.ts'

Creates a packed copy of start and end times with submissionBits

#### Params:

Name | Type | Attribute | Description
start | number |  | Start time in seconds since epoch
end | number |  | End time in seconds since epoch
submissionBits | number |  | Submission bits - can be created using mkSubmissionBits

#### Return:

BN | Returns a `bn.js` BigNum of the packed values. Format: [submissionBits(16)][startTime(64)][endTime(64)]

### public mkSignedBallotForProxy(ballotId: string, sequence: number, voteData: string, extra: string, privateKey: string, opts: object): object source

    import {mkSignedBallotForProxy} from 'sv-lib/src/ballotBox.ts'

Take the arguments and produce web3 data fitting the `submitProxyVote` method.

#### Params:

Name | Type | Attribute | Description
ballotId | string |  | a BN.js or Hex ballotId
sequence | number |  | the sequence number to use (0 < sequence < 2^32)
voteData | string |  | the vote data to use, should be 32 bytes hex encoded
extra | string |  | any extra data included with the vote (such as curve25519 pubkeys)
privateKey | string |  | the privkey used to sign
opts | object |  | options: skipSequenceSizeCheck: boolean (will not throw if sequence is >= 2^32)

#### Return:

object | { proxyReq (bytes32[5]), extra (bytes) } in the required format for `submitProxyVote`

### public mkSubmissionBits(toCombine: number[]): number source

    import {mkSubmissionBits} from 'sv-lib/src/ballotBox.ts'

This combines flags into a finished submissionBits. It also does some validation.

#### Params:

Name | Type | Attribute | Description
toCombine | number[] |  | Array of all submission flags to combine. See SV.ballotBox.flags for flag options. All flags must be a power of 2 (which indicates they occupy a single bit in the number when combining).

#### Return:

number | A 16 bit integer of combined flags.

### public networkName(networkId: *): string source

    import {networkName} from 'sv-lib/src/const.ts'

#### Params:

Name | Type | Attribute | Description
networkId | * |  |

#### Return:

string

### public prepareEd25519Delegation(address: *, nonce: *): Bytes32 source

    import {prepareEd25519Delegation} from 'sv-lib/src/light.ts'

Generate a packed Ed25519Delegation instruction for use with the smart contract or API

#### Params:

Name | Type | Attribute | Description
address | * |  | An ethereum address to delegate to
nonce | * |  | A nonce in hex that is 3 bytes (6 characters as hex)

#### Return:

Bytes32 | The hex string (with 0x prefix) of the delegation instruction

### public async prepareWeb3BBVoteTx(txInfo: object, svNetwork: object): object source

    import {prepareWeb3BBVoteTx} from 'sv-lib/src/ballotBox.ts'

Prepares a transaction for sending with the users web3 browser

#### Params:

Name | Type | Attribute | Description
txInfo | object |  | Object literal containing the information required to generate the web3 transaction.
svNetwork | object |  | config object containing svNetwork

#### Return:

object | Returns an object with all fields required to cast the transaction

### public async resolveEnsAddress(objectPattern: {"resolver": *}, ensName: *): * source

    import {resolveEnsAddress} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
objectPattern | {"resolver": *} | default: {"resolver":null} |
ensName | * |  |

#### Return:

*

### public stellarPkToHex(pubKey: *): * source

    import {stellarPkToHex} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
pubKey | * |  |

#### Return:

*

### public verifySignedBallotForProxy(proxyVote: ProxyVote, opts: *): {verified: bool, address: EthAddress} source

    import {verifySignedBallotForProxy} from 'sv-lib/src/ballotBox.ts'

Verify a signed vote to be submitted via proxy as generated by `mkSignedBallotForProxy`

#### Params:

Name | Type | Attribute | Description
proxyVote | ProxyVote |  | The ProxyVote object
opts | * | optional default: {} | Not used currently; for future options

#### Return:

{verified: bool, address: EthAddress}

### public async weiToCents(objectPattern: {"payments": *}, wei: *): * source

    import {weiToCents} from 'sv-lib/src/light.ts'

#### Params:

Name | Type | Attribute | Description
objectPattern | {"payments": *} | default: {"payments":null} |
wei | * |  |

#### Return:

*