本文へスキップ
このページは英語からの機械翻訳を使用しており、誤りや不明瞭な表現が含まれている可能性があります。最も正確な情報については、オリジナルの英語版をご覧ください。頻繁な更新のため、一部のコンテンツはオリジナルの英語になっている可能性があります。Crowdinでの取り組みに参加して、このページの翻訳改善にご協力ください。 (Crowdin translation page, Contributing guide)

caver.account

caver.account はアカウントを更新する際に使用するアカウントに関する機能を提供するパッケージである。

クラス

Account


const account = new caver.account(address, accountKey)

Accountは、kaiaブロックチェーンプラットフォーム(kaia)のアカウントのAccountKeyを更新するために必要な情報を含むクラスです。 これは caver.account パッケージのデフォルトクラスである。 公開鍵文字列を持つアカウント・インスタンスを作成するには、caver.account.create を参照。

プロパティ

名称タイプ説明
addressstring更新するアカウントのアドレス。
accountKeyobjectアカウントで使用する新しい accountKey。 これは、AccountKeyLegacyAccountKeyPublicAccountKeyFailAccountKeyWeightedMultiSig、またはAccountKeyRoleBasedのインスタンスである。 トランザクションが実行されると、kaiaに保存されているアカウントのaccountKeyがこれに変更される。

AccountKeyLegacy


const accountKeyLegacy = new caver.account.accountKey.accountKeyLegacy()

AccountKeyLegacyは、KaiaのアカウントのAccountKeyをAccountKeyLegacyで更新するために使用される。 AccountKeyLegacyを持つAccountインスタンスを作成するには、caver.account.createWithAccountKeyLegacy を参照してください。

AccountKeyPublic


const accountKeyPublic = new caver.account.accountKey.accountKeyPublic(publicKey)

AccountKeyPublicは、kaiaのアカウントのAccountKeyをAccountKeyPublicで更新するために使用される。 AccountKeyをAccountKeyPublicに更新することで、既存のAccountKeyを新しい公開鍵に変更することができます。 この変更は、秘密鍵をアカウントのアドレスから切り離すときに必要です。 詳細はAccountUpdateおよびAccountKeyを参照。

AccountKeyPublicを持つAccountインスタンスを作成するには、caver.account.createまたはcaver.account.createWithAccountKeyPublicを参照してください。

プロパティ

名称タイプ説明
publicKeystring公開鍵の文字列。

AccountKeyFail


const accountKeyFail = new caver.account.accountKey.accountKeyFail()

AccountKeyFailは、AccountKeyFailでカイアのアカウントのAccountKeyを更新するために使用される。 AccountKeyFail付きのAccountインスタンスを作成するには、caver.account.createWithAccountKeyFail を参照してください。

AccountKeyWeightedMultiSig


const accountKeyWeightedMultiSig = new caver.account.accountKey.accountKeyWeightedMultiSig(threshold, weightedPublicKeys)

AccountKeyWeightedMultiSigは、AccountKeyWeightedMultiSigを使用してkaiaのアカウントのAccountKeyを更新するために使用される。 AccountKeyWeightedMultiSigに更新することで、既存のAccountKeyを新しい公開鍵に変更することができます。 この変更は、秘密鍵をアカウントのアドレスから切り離すときに必要です。 詳細はAccountUpdateおよびAccountKeyを参照。

AccountKeyWeightedMultiSigを使用してAccountインスタンスを作成するには、caver.account.createまたはcaver.account.createWithAccountKeyWeightedMultiSigを参照してください。

プロパティ

名称タイプ説明
thresholdnumber検証のしきい値。
weightedPublicKeys配列WeightedPublicKey] の配列。

AccountKeyRoleBased


const accountKeyRoleBased = new caver.account.accountKey.accountKeyRoleBased(accountKeyArray)

AccountKeyRoleBasedは、AccountKeyRoleBasedでカイアのアカウントのAccountKeyを更新するために使用される。 AccountKeyをAccountKeyRoleBasedに更新すると、ロールごとに割り当てられたAccountKeyを変更することができます。 詳しくはAccountUpdateおよびAccountKeyを参照のこと。

AccountKeyRoleBasedを使用してアカウントインスタンスを作成するには、caver.account.createまたはcaver.account.createWithAccountKeyRoleBasedを参照してください。

プロパティ

名称タイプ説明
accountKeyArray配列role で使用する accountKey を定義する配列。 各ロールは、AccountKeyLegacyAccountKeyPublicAccountKeyFail、またはAccountKeyWeightedMultiSigで定義できる。

WeightedPublicKey


const weightedPublicKey = new caver.account.accountKey.weightedPublicKey(weight, publicKey)

WeightedPublicKeyは公開鍵とその重みを含む。 WeightedPublicKeyは公開鍵と鍵の重みを含むクラスで、AccountKeyWeightedMultiSigで使用される。

プロパティ

名称タイプ説明
weightnumber公開鍵の重さ。 ウェイトは、公開鍵の重み付き合計がAccountKeyWeightedMultiSigオブジェクトの閾値より大きいかどうかをチェックするために使用される。
publicKeystring公開鍵の文字列。

WeightedMultiSigOptions


const weightedMultiSigOptions = new caver.account.weightedMultiSigOptions(threshold, weights)

WeightedMultiSigOptionsは閾値と重みを含む。 WeightedMultiSigOptions は AccountKeyWeightedMultiSig のオプションを定義するクラスである。

プロパティ

名称タイプ説明
thresholdnumber検証のしきい値。
weights配列キーの重みの配列。

caver.account.create


caver.account.create(address, accountKey [, options])

アドレスと accountKey を持つ Account インスタンスを生成します。

accountKey が公開鍵文字列の場合、AccountKeyPublic を accountKey とする Account インスタンスが作成される。 accountKey が公開鍵文字列を含む配列の場合、AccountKeyWeightedMultiSig を accountKey とする Account インスタンスが生成される。 最後のパラメータとしてオプションが定義されていない場合、各キーに対して、しきい値1、重み付け1のデフォルト・オプションを使用して作成される。 accountKey が、ロールごとに使用される accountKey を含む配列である場合、AccountKeyRoleBased を持つ Account インスタンスが作成されます。 オプションはWeightedMultiSigOptionsでロールごとに定義されなければならない。 オプションが定義されていない場合、複数の公開鍵を使用するロールにはデフォルトのオプションが使用されます。 使い方は下記の例を参考にしてください。

パラメーター

名称タイプ説明
addressstring更新するアカウントのアドレス。
accountKeystring \Array
optionsWeightedMultiSigOptions \Array

リターン・バリュー

タイプ説明
Accountアカウントのインスタンスが返される。


// Create an Account instance with a public key string -> Account with AccountKeyPublic
> caver.account.create('0x{address in hex}', '0x034f1...')
Account {
_address: '0xc771822ad361898a330df0169f2382ee92f6286d',
_accountKey: AccountKeyPublic { _publicKey: '0x034f1...' }
}
// Create an Account instance with an array of public keys -> Account with AccountKeyWeightedMultiSig
> caver.account.create('0x{address in hex}', ['0x034f1...', '0xfe4b8...'])
Account {
_address: '0xc771822ad361898a330df0169f2382ee92f6286d',
_accountKey:
AccountKeyWeightedMultiSig {
_threshold: 1,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0x034f1...' },
WeightedPublicKey { _weight: 1, _publicKey: '0xfe4b8...' }
]
}
}
// Create an Account instance with an array of public keys with WeightedMultiSigOptions -> Account with AccountKeyWeightedMultiSig
> const options = new caver.account.weightedMultiSigOptions(2, [1, 1])
> caver.account.create('0x{address in hex}', ['0x034f1...', '0xfe4b8...'], options)
Account {
_address: '0xc771822ad361898a330df0169f2382ee92f6286d',
_accountKey:
AccountKeyWeightedMultiSig {
_threshold: 2,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0x034f1...' },
WeightedPublicKey { _weight: 1, _publicKey: '0xfe4b8...' }
]
}
}
// Create an Account instance with an array in which keys to be used for each role are defined as an array -> Account with AccountKeyRoleBased
> const publicKeys = [
['0xd8510...', '0xaa105...'],
['0xd8510...'],
['0xd8510...', '0xceeee...']
]
> caver.account.create('0x{address in hex}', publicKeys)
Account {
_address: '0xc771822ad361898a330df0169f2382ee92f6286d',
_accountKey:
AccountKeyRoleBased {
_accountKeys: [
AccountKeyWeightedMultiSig {
_threshold: 1,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0xd8510...' },
WeightedPublicKey { _weight: 1, _publicKey: '0xaa105...' }
]
},
AccountKeyPublic { _publicKey: '0xd8510...' },
AccountKeyWeightedMultiSig {
_threshold: 1,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0xd8510...' },
WeightedPublicKey { _weight: 1, _publicKey: '0xceeee...' }
]
}
]
}
}
// Create an Account instance with an array in which keys to be used for each role are defined as an array with an array of WeightedMultiSigOptions -> Account with AccountKeyRoleBased
> const publicKeys = [
['0xd8510...', '0xaa105...'],
['0xd8510...'],
['0xd8510...', '0xceeee...']
]
> const options = [
new caver.account.weightedMultiSigOptions(2, [1, 1]),
new caver.account.weightedMultiSigOptions(),
new caver.account.weightedMultiSigOptions(3, [1, 2])
]
> caver.account.create('0x{address in hex}', publicKeys, options)
Account {
_address: '0xc771822ad361898a330df0169f2382ee92f6286d',
_accountKey:
AccountKeyRoleBased {
_accountKeys: [
AccountKeyWeightedMultiSig {
_threshold: 2,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0xd8510...' },
WeightedPublicKey { _weight: 1, _publicKey: '0xaa105...' }
]
},
AccountKeyPublic { _publicKey: '0xd8510...' },
AccountKeyWeightedMultiSig {
_threshold: 3,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0xd8510...' },
WeightedPublicKey { _weight: 2, _publicKey: '0xceeee...' }
]
}
]
}
}

caver.account.createFromRLPEncoding


caver.account.createFromRLPEncoding(address, rlpEncodedKey)

RLP エンコードされた AccountKey から Account インスタンスを作成します。

パラメーター

名称タイプ説明
addressstring更新するアカウントのアドレス。
rlpEncodedKeystringAccountKeyをRLPエンコードした文字列。

リターン・バリュー

タイプ説明
Accountアカウントのインスタンスが返される。


> caver.account.createFromRLPEncoding('0x{address in hex}', '0x04f84b02f848e301a102c10b598a1a3ba252acc21349d61c2fbd9bc8c15c50a5599f420cccc3291f9bf9e301a1021769a9196f523c419be50c26419ebbec34d3d6aa8b59da834212f13dbec9a9c1')
Account {
_address: '0x9ea5b871e7bef65868a0d278be3fc6cdbee543ee',
_accountKey:
AccountKeyWeightedMultiSig {
_threshold: 2,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0x02c10...' },
WeightedPublicKey { _weight: 1, _publicKey: '0x02176...' }
]
}
}

caver.account.createWithAccountKeyLegacy


caver.account.createWithAccountKeyLegacy(address)

AccountKeyLegacy を accountKey として持つ Account インスタンスを作成します。

パラメーター

名称タイプ説明
addressstring更新するアカウントのアドレス。

リターン・バリュー

タイプ説明
Accountアカウントのインスタンスが返される。


> caver.account.createWithAccountKeyLegacy('0x{address in hex}')
Account {
_address: '0x9ea5b871e7bef65868a0d278be3fc6cdbee543ee',
_accountKey: AccountKeyLegacy {}
}

caver.account.createWithAccountKeyPublic


caver.account.createWithAccountKeyPublic(address, publicKey)

AccountKeyPublic を accountKey として持つ Account インスタンスを作成します。

パラメーター

名称タイプ説明
addressstring更新するアカウントのアドレス。
publicKeystring公開鍵の文字列。

リターン・バリュー

タイプ説明
Accountアカウントのインスタンスが返される。


> caver.account.createWithAccountKeyPublic('0x{address in hex}', '0xb5a9a...')
Account {
_address: '0x9ea5b871e7bef65868a0d278be3fc6cdbee543ee',
_accountKey: AccountKeyPublic { _publicKey: ,'0xb5a9a...' }
}

caver.account.createWithAccountKeyFail


caver.account.createWithAccountKeyFail(address)

AccountKeyFail を AccountKey として持つ Account インスタンスを作成します。

パラメーター

名称タイプ説明
addressstring更新するアカウントのアドレス。

リターン・バリュー

タイプ説明
Accountアカウントのインスタンスが返される。


> caver.account.createWithAccountKeyFail('0x{address in hex}')
Account {
_address: '0x9ea5b871e7bef65868a0d278be3fc6cdbee543ee',
_accountKey: AccountKeyFail {}
}

caver.account.createWithAccountKeyWeightedMultiSig


caver.account.createWithAccountKeyWeightedMultiSig(address, publicKeyArray [, options])

AccountKeyWeightedMultiSig を accountKey とする Account インスタンスを作成します。

パラメーター

名称タイプ説明
addressstring更新するアカウントのアドレス。
publicKeyArray配列複数の公開鍵文字列を含む配列。
optionsWeightedMultiSigOptions (重み付きマルチシグオプション)(オプション) しきい値と重みの配列を定義する WeightedMultiSigOptions インスタンス。

リターン・バリュー

タイプ説明
Accountアカウントのインスタンスが返される。


// create an Account instance without options
> caver.account.createWithAccountKeyWeightedMultiSig('0x{address in hex}', ['0xb5a9a...', '0xfe4b8...'])
Account {
_address: '0xc771822ad361898a330df0169f2382ee92f6286d',
_accountKey:
AccountKeyWeightedMultiSig {
_threshold: 1,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0xb5a9a...' },
WeightedPublicKey { _weight: 1, _publicKey: '0xfe4b8...' }
]
}
}
// create an Account instance with options
> const options = new caver.account.weightedMultiSigOptions(2, [1, 1])
> caver.account.createWithAccountKeyWeightedMultiSig('0x{address in hex}', ['0xb5a9a...', '0xfe4b8...'], options)
Account {
_address: '0xc771822ad361898a330df0169f2382ee92f6286d',
_accountKey:
AccountKeyWeightedMultiSig {
_threshold: 2,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0xb5a9a...' },
WeightedPublicKey { _weight: 1, _publicKey: '0xfe4b8...' }
]
}
}

caver.account.createWithAccountKeyRoleBased


caver.account.createWithAccountKeyRoleBased(address, roledBasedPublicKeyArray [, options])

AccountKeyRoleBased を accountKey とする Account インスタンスを作成します。

パラメーター

名称タイプ説明
addressstring更新するアカウントのアドレス。
roledBasedPublicKeyArray配列各ロールの公開鍵文字列の配列を含む二次元配列。
options配列(オプション) 各ロールの WeightedMultiSigOptions インスタンスを含む配列。

リターン・バリュー

タイプ説明
Accountアカウントのインスタンスが返される。


// create an Account instance without options
> const publicKeys = [
['0x034f1...', '0xfe4b8...'],
['0xb5a9a...'],
['0x034f1...', '0xb5a9a...']
]
> caver.account.createWithAccountKeyRoleBased('0x{address in hex}', publicKeys)
Account {
_address: '0xc771822ad361898a330df0169f2382ee92f6286d',
_accountKey:
AccountKeyRoleBased {
_accountKeys: [
AccountKeyWeightedMultiSig {
_threshold: 1,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0x034f1...' },
WeightedPublicKey { _weight: 1, _publicKey: '0xfe4b8...' }
]
},
AccountKeyPublic { _publicKey: '0xb5a9a...' },
AccountKeyWeightedMultiSig {
_threshold: 1,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0x034f1...' },
WeightedPublicKey { _weight: 1, _publicKey: '0xb5a9a...' }
]
}
]
}
}
// create an Account instance with options
> const publicKeys = [
['0x034f1...', '0xfe4b8...'],
['0xb5a9a...'],
['0x034f1...', '0xb5a9a...']
]
> const options = [
new caver.account.weightedMultiSigOptions(2, [1, 1]),
new caver.account.weightedMultiSigOptions(),
new caver.account.weightedMultiSigOptions(3, [1, 2])
]
> caver.account.createWithAccountKeyRoleBased('0x{address in hex}', publicKeys, options)
Account {
_address: '0xc771822ad361898a330df0169f2382ee92f6286d',
_accountKey:
AccountKeyRoleBased {
_accountKeys: [
AccountKeyWeightedMultiSig {
_threshold: 2,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0x034f1...' },
WeightedPublicKey { _weight: 1, _publicKey: '0xfe4b8...' }
]
},
AccountKeyPublic { _publicKey: '0xb5a9a...' },
AccountKeyWeightedMultiSig {
_threshold: 3,
_weightedPublicKeys: [
WeightedPublicKey { _weight: 1, _publicKey: '0x034f1...' },
WeightedPublicKey { _weight: 2, _publicKey: '0xb5a9a...' }
]
}
]
}
}

caver.account.accountKey.decode


caver.account.accountKey.decode(rlpEncodedAccountKey)

AccountKey の RLP エンコード文字列をデコードし、AccountKeyLegacyAccountKeyPublicAccountKeyFailAccountKeyWeightedMultiSig、または AccountKeyRoleBased インスタンスを返す。

パラメーター

名称タイプ説明
rlpEncodedAccountKeystringAccountKeyをRLPエンコードした文字列。

リターン・バリュー

タイプ説明
AccountKeyWeightedMultiSig \AccountKey インスタンスが返される。


> caver.account.accountKey.decode('0x02a102c10b598a1a3ba252acc21349d61c2fbd9bc8c15c50a5599f420cccc3291f9bf9')
AccountKeyPublic { _publicKey: '0x02c10b598a1a3ba252acc21349d61c2fbd9bc8c15c50a5599f420cccc3291f9bf9' }

account.getRLPEncodingAccountKey


account.getRLPEncodingAccountKey()

AccountKey を RLP エンコードした文字列を返します。

リターン・バリュー

タイプ説明
stringAccountKey を RLP エンコードした文字列。


> const account = caver.account.create('0x{address in hWeightedMultiSigOptionsex}', '0x034f1...')
> account.getRLPEncodingAccountKey()
'0x02a102d851040f46d61a042a787cca34ad12bc43e51f01ad0b22270cfc25c15c4b4e22'

ページを改善してください。