Go API

SmartAccount Factories

NewECDSA and NewMultisigECDSA for SmartAccount

NewECDSASmartAccount

Creates a SmartAccount instance that uses single ECDSA key for signing payload.

ParameterTypeDescription
addresscommon.AddressAccount address.
privateKeystringThe ECDSA private key.
client*clients.clientThe client to connect to. Can be nil for offline usage.

func NewECDSASmartAccount(address common.Address, privateKey string, client *clients.Client) *SmartAccount

Example

privateKey := os.Getenv("PRIVATE_KEY")
address := common.HexToAddress("<ACCOUNT ADDRESS>")
ZkSyncEraProvider := "https://sepolia.era.zksync.dev"

client, err := clients.DialBase(ZkSyncEraProvider)
if err != nil {
  log.Panic(err)
}
defer client.Close()

account := accounts.NewECDSASmartAccount(address, privateKey, client)

NewMultisigECDSASmartAccount

Creates a SmartAccount instance that uses multiple ECDSA keys for signing payloads. The signature is generated by concatenating signatures created by signing with each key individually.

ParameterTypeDescription
addresscommon.AddressAccount address.
privateKeys[]stringThe list of the ECDSA private keys.
client*clients.ClientThe client to connect to. Can be nil for offline usage.
NewMultisigECDSASmartAccount(address common.Address, privateKeys []string, client *clients.Client) *SmartAccount

Example

privateKey1 := os.Getenv("PRIVATE_KEY1")
privateKey2 := os.Getenv("PRIVATE_KEY2")
address := common.HexToAddress("<ACCOUNT ADDRESS>")
ZkSyncEraProvider := "https://sepolia.era.zksync.dev"

client, err := clients.DialBase(ZkSyncEraProvider)
if err != nil {
  log.Panic(err)
}
defer client.Close()

account := accounts.NewMultisigECDSASmartAccount(address, []string{privateKey1, privateKey2}, client)

Made with ❤️ by the ZKsync Community