contracts

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2023 License: GPL-3.0 Imports: 26 Imported by: 0

README

How to generate golang code for contract deploy and call

An example is blocksigner

step 1: generate contract abi and bin with solc

- cd contracts/blocksigner
- solc --abi --bin contract/BlockSigner.sol -o contract/build/ --overwrite --optimize

step 2:generate golang code

- go run ../../cmd/abigen/ --abi contract/build/BlockSigner.abi --bin contract/build/BlockSigner.bin --pkg contract --type BlockSigner --out contract/BlockSigner.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTxOpeningRandomize

func BuildTxOpeningRandomize(nonce uint64, gasPrice *big.Int, randomizeAddr common.Address, randomizeKey []byte) (*types.Transaction, error)

BuildTxOpeningRandomize Build tx to set opening into Randomize.

func BuildTxSecretRandomize

func BuildTxSecretRandomize(nonce uint64, gasPrice *big.Int, randomizeAddr common.Address, epocNumber uint64, randomizeKey []byte) (*types.Transaction, error)

BuildTxSecretRandomize Build tx to set secret into Randomize.

func BuildTxSignBlockSigner added in v0.2.0

func BuildTxSignBlockSigner(blockNumber *big.Int, blockHash common.Hash, nonce uint64, gasPrice *big.Int, blockSigner common.Address) *types.Transaction

BuildTxSignBlockSigner Build tx to sign into BlockSigner.

func CreateTransactionSetOpening added in v0.2.0

func CreateTransactionSetOpening(chainConfig *params.ChainConfig, pool *core.TxPool, manager *accounts.Manager, header *types.Header, chainDb ethdb.Database, signer common.Address) error

CreateTransactionSetOpening Send tx set opening to smart contract randomize.

func CreateTransactionSetSecret added in v0.2.0

func CreateTransactionSetSecret(chainConfig *params.ChainConfig, pool *core.TxPool, manager *accounts.Manager, header *types.Header, chainDb ethdb.Database, signer common.Address) error

CreateTransactionSetSecret Send tx set secret to smart contract randomize.

func CreateTransactionSign added in v0.2.0

func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, manager *accounts.Manager, eb common.Address, toSign, header *types.Header) error

CreateTransactionSign Send tx sign for block number to smart contract blockSigner.

func Decrypt

func Decrypt(key []byte, cryptoText string) string

Decrypt from base64 to decrypted string

func DecryptRandomizeFromSecretsAndOpening

func DecryptRandomizeFromSecretsAndOpening(secrets [][32]byte, opening [32]byte) (int64, error)

DecryptRandomizeFromSecretsAndOpening Decrypt randomize from secrets and opening.

func Encrypt

func Encrypt(key []byte, text string) string

Encrypt string to base64 crypto using AES

func GenerateM2FromRandomize added in v0.2.2

func GenerateM2FromRandomize(randomizes []int64, masternodes []common.Address) ([]common.Address, error)

GenerateM2FromRandomize Generate m2 listing from randomize array.

func GetBlockSignersFromContract added in v0.2.2

func GetBlockSignersFromContract(client bind.ContractBackend, blockHash common.Hash, blockNumber *big.Int) ([]common.Address, error)

GetBlockSignersFromContract Get signers signed for blockHash from blockSigner contract.

func GetBlockSignersFromState added in v0.2.2

func GetBlockSignersFromState(statedb *state.StateDB, blockHash common.Hash) []common.Address

func GetCandidateCapFromState added in v0.2.0

func GetCandidateCapFromState(statedb *state.StateDB, candidate common.Address) *big.Int

func GetCandidateOwnerFromState added in v0.2.0

func GetCandidateOwnerFromState(statedb *state.StateDB, candidate common.Address) common.Address

func GetCandidatesFromContract added in v0.2.2

func GetCandidatesFromContract(client *ethclient.Client, blockNumber *big.Int) (map[common.Address]*big.Int, error)

GetCandidatesFromContract get candidates and caps from contract

func GetCandidatesFromState added in v0.2.0

func GetCandidatesFromState(statedb *state.StateDB) []common.Address

func GetLocDynamicArrAtElement added in v0.2.0

func GetLocDynamicArrAtElement(slotHash common.Hash, index uint64, elementSize uint64) common.Hash

func GetLocFixedArrAtElement added in v0.2.0

func GetLocFixedArrAtElement(slot uint64, index uint64, elementSize uint64) common.Hash

func GetLocMappingAtKey added in v0.2.0

func GetLocMappingAtKey(key common.Hash, slot uint64) *big.Int

func GetLocOfStructElement added in v0.2.0

func GetLocOfStructElement(locOfStruct *big.Int, elementSlotInstruct *big.Int) common.Hash

func GetLocSimpleVariable added in v0.2.0

func GetLocSimpleVariable(slot uint64) common.Hash

func GetOpeningFromState added in v0.2.0

func GetOpeningFromState(statedb *state.StateDB, address common.Address) [32]byte

func GetRandomizeFromContract added in v0.2.0

func GetRandomizeFromContract(client bind.ContractBackend, addrMasternode common.Address, blockNumber *big.Int) (int64, error)

GetRandomizeFromContract random from randomize contract.

func GetSecretFromState added in v0.2.0

func GetSecretFromState(statedb *state.StateDB, address common.Address) [][32]byte

func GetVoterCapFromState added in v0.2.0

func GetVoterCapFromState(statedb *state.StateDB, candidate, voter common.Address) *big.Int

func GetVotersFromState added in v0.2.0

func GetVotersFromState(statedb *state.StateDB, candidate common.Address) []common.Address

func RandStringByte

func RandStringByte(n int) []byte

RandStringByte Generate random string.

Types

This section is empty.

Directories

Path Synopsis
Package checkpointoracle is a an on-chain light client checkpoint oracle.
Package checkpointoracle is a an on-chain light client checkpoint oracle.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL