caver.account

caver.account는 계정 업데이트시 사용 되며 Account에 관련된 기능을 제공하는 패키지입니다.

Class

계정

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

Account는 Klaytn 계정의 AccountKey를 업데이트하기 위해 필요한 정보를 포함하는 클래스입니다. caver.account 패키지의 기본 클래스입니다. 공개키(들)을 이용해 Account 인스턴스를 만들고자 한다면 caver.account.create를 참고하세요.

속성

Name
Type
Description

address

string

업데이트 할 계정의 주소입니다.

accountKey

object

계정에 사용될 새 accountKey입니다. AccountKeyLegacy, AccountKeyPublic, AccountKeyFail, AccountKeyWeightedMultiSig 또는 AccountKeyRoleBased의 인스턴스일 수 있습니다. 트랜잭션이 실행되면 Klaytn에 저장된 계정의 accountKey가 이렇게 변경됩니다.

AccountKeyLegacy

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

AccountKeyLegacyAccountKeyLegacy를 통해 Klaytn 계정의 AccountKey를 업데이트할 때 사용됩니다. AccountKeyLegacy를 가지고 Account 인스턴스를 생성하고자 한다면 caver.account.createWithAccountKeyLegacy를 참고하세요.

AccountKeyPublic

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

AccountKeyPublicAccountKeyPublic를 이용해 Klaytn 계정의 AccountKey를 업데이트할 때 사용됩니다. AccountKey를 AccountKeyPublic로 업데이트하면 기존의 AccountKey가 새로운 공개키로 바뀌며, 이는 Klaytn 트랜잭션 검증에 사용됩니다. 계정의 개인키를 주소로부터 분리할 때 필요한 업데이트입니다. 자세한 사항은 AccountUpdateAccountKey를 참고하세요.

AccountKeyPublic로 Account 인스턴스를 만들고자 한다면 caver.account.create or caver.account.createWithAccountKeyPublic를 참고하세요.

properties

Name
Type
Description

publicKey

string

공개키 문자열입니다.

AccountKeyFail

AccountKeyFailAccountKeyFail을 통해 Klaytn 계정의 AccountKey를 업데이트할 때 사용됩니다. AccountKeyFail을 사용하여 Account 인스턴스를 만들고자 한다면 caver.account.createWithAccountKeyFail를 참고하세요.

AccountKeyWeightedMultiSig

AccountKeyWeightedMultiSigAccountKeyWeightedMultiSig를 사용해 Klaytn 계정의 AccountKey를 업데이트할 때 사용합니다. AccountKey를 AccountKeyWeightedMultiSig로 업데이트하면 기존의 AccountKey가 새로운 공개키로 바뀌며, 이는 Klaytn 트랜잭션 검증에 사용됩니다. This change is necessary when you decouple your private key from the address of your account. See AccountUpdate and AccountKey for details.

AccountKeyWeightedMultiSig로 Account 인스턴스를 만들고자 한다면 caver.account.create or caver.account.createWithAccountKeyWeightedMultiSig를 참고하세요.

properties

Name
Type
Description

threshold

number

검증 임계값입니다.

weightedPublicKeys

Array

WeightedPublicKey의 배열입니다.

AccountKeyRoleBased

AccountKeyRoleBasedAccountKeyRoleBased를 통해 Klaytn 계정의 AccountKey를 업데이트할 때 사용됩니다. AccountKey를 AccountKeyRoleBased로 업데이트함으로써 Klaytn 트랜잭션 검증에 사용되는 각 역할에 할당된 AccountKey(들)을 변경할 수 있습니다. 자세한 사항은 AccountUpdateAccountKey를 참고하세요.

AccountKeyRoleBased로 Account 인스턴스를 만들고자 한다면 caver.account.create or caver.account.createWithAccountKeyRoleBased를 참고하세요.

properties

Name
Type
Description

accountKeyArray

Array

역할에 사용되는 키를 정의하는 배열입니다. 각 역할은 [AccountKeyLegacy, AccountKeyPublic, AccountKeyFail, AccountKeyWeightedMultiSig 또는 AccountKeyRoleBased](#accountkeylegacy)로 정의될 수 있습니다.

WeightedPublicKey

WeightedPublicKey contains a public key and its weight. WeightedPublicKey는 공개키와 그 가중치를 포함하는 클래스로, AccountKeyWeightedMultiSig에 사용됩니다.

properties

Name
Type
Description

weight

number

공개키의 가중치입니다. 공개키의 가중치 합계가 AccountKeyWeightedMultiSig 객체의 임계값을 초과하는지 여부를 확인하는 데 사용됩니다.

publicKey

string

The public key string.

WeightedMultiSigOptions

WeightedMultiSigOptions는 임계값과 가중치를 포함합니다. WeightedMultiSigOptions는 AccountKeyWeightedMultiSig의 옵션을 정의하는 클래스입니다.

properties

Name
Type
Description

threshold

number

The validation threshold.

가중치

Array

키 가중치의 배열입니다.

caver.account.create

주소와 accountKey를 지닌 Account 인스턴스를 생성합니다.

accountKey가 공개키 문자열인 경우, accountKey가 AccountKeyPublic인 Account 인스턴스가 생성됩니다. accountKey가 공개키 문자열을 포함한 배열인 경우, accountKey가 AccountKeyWeightedMultiSig인 Account 인스턴스가 생성됩니다. 옵션들이 마지막 파라미터로 정의되지 않은 경우 기본값으로 임계값이 1, 각 키의 가중치가 1로 설정되어 생성됩니다. accountKey가 각 역할에 사용되는 accountKeys를 포함한 배열인 경우, AccountKeyRoleBased를 지닌 Account 인스턴스가 생성됩니다. 옵션들은 WeightedMultiSigOptions를 통해 각 역할에 정의되어야 합니다. 옵션들이 정의되어 있지 않다면, 다수의 공개키를 사용하는 역할들에 대해 기본 옵션이 사용됩니다. 사용법은 아래 예시를 참고하세요.

Parameters

Name
Type
Description

address

string

The address of account to be updated.

accountKey

string | Array

공개키 문자열, 공개키(들)의 배열, 또는 각 요소가 각 역할에 사용될 키(들) 의 배열을 포함하는 2차원 배열입니다.

options

(선택 사항) AccountKeyWeigthedMultiSig에 대한 옵션들입니다.

Return Value

Type
Description

Account 인스턴스가 반환됩니다.

Example

caver.account.createFromRLPEncoding

RLP 인코딩된 AccountKey로부터 Account 인스턴스를 생성합니다.

Parameters

Name
Type
Description

address

string

업데이트 할 계정의 주소입니다.

rlpEncodedKey

string

AccountKey의 RLP 인코딩된 문자열입니다.

Return Value

Type
Description

The account instance is returned.

Example

caver.account.createWithAccountKeyLegacy

AccountKeyLegacy를 accountKey로 지닌 Account 인스턴스를 생성합니다.

Parameters

Name
Type
Description

address

string

The address of an account to be updated.

Return Value

Type
Description

The account instance is returned.

Example

caver.account.createWithAccountKeyPublic

AccountKeyPublic를 accountKey로 지닌 Account 인스턴스를 생성합니다.

Parameters

Name
Type
Description

address

string

The address of an account to be updated.

publicKey

string

The public key string.

Return Value

Type
Description

The account instance is returned.

Example

caver.account.createWithAccountKeyFail

AccountKeyFail를 accountKey로 지닌 Account 인스턴스를 생성합니다.

Parameters

Name
Type
Description

address

string

The address of an account to be updated.

Return Value

Type
Description

The account instance is returned.

Example

caver.account.createWithAccountKeyWeightedMultiSig

AccountKeyWeightedMultiSig를 accountKey로 지닌 Account 인스턴스를 생성합니다.

Parameters

Name
Type
Description

address

string

The address of an account to be updated.

publicKeyArray

Array

다수의 공개키 문자열을 포함한 배열입니다.

options

(선택 사항) 임계값과 가중치 배열을 정의하는 WeightedMultiSigOptions 인스턴스입니다.

Return Value

Type
Description

The account instance is returned.

Example

caver.account.createWithAccountKeyRoleBased

AccountKeyRoleBased를 accountKey로 지닌 Account 인스턴스를 생성합니다.

Parameters

Name
Type
Description

address

string

The address of an account to be updated.

roledBasedPublicKeyArray

Array

각 역할에 대해 공개키 문자열의 배열을 포함하고 있는 2차원 배열입니다.

options

Array

(선택 사항) 각 역할에 대해 WeightedMultiSigOptions 인스턴스를 포함하는 배열입니다.

Return Value

Type
Description

The account instance is returned.

Example

caver.account.accountKey.decode

AccountKey의 RLP 인코딩된 문자열을 디코딩하며, AccountKeyLegacy, AccountKeyPublic, AccountKeyFail, AccountKeyWeightedMultiSig 또는 AccountKeyRoleBased 인스턴스를 반환합니다.

Parameters

Name
Type
Description

rlpEncodedAccountKey

string

AccountKey의 RLP 인코딩된 문자열입니다.

Return Value

Type
Description

Example

account.getRLPEncodingAccountKey

AccountKey의 RLP 인코딩된 문자열을 반환합니다.

Return Value

Type
Description

string

AccountKey의 RLP 인코딩된 문자열입니다 .

Example

Last updated

Was this helpful?