Skip to content

Commit

Permalink
Update docs due to pricing mode changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmyshchyshyn committed Dec 19, 2024
1 parent 212a58f commit e95d8a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ import {
CLValueUInt64,
CLValueUInt512,
Duration,
FixedMode,
HttpHandler,
InitiatorAddr,
KeyAlgorithm,
Expand All @@ -134,7 +133,8 @@ import {
TransactionTarget,
TransactionV1,
TransactionV1Payload,
TransactionEntryPointEnum
TransactionEntryPointEnum,
PaymentLimitedMode
} from 'casper-js-sdk';

const rpcHandler = new HttpHandler('http://<Node Address>:7777/rpc');
Expand All @@ -145,10 +145,11 @@ const timestamp = new Timestamp(new Date());
const paymentAmount = '20000000000000';

const pricingMode = new PricingMode();
const fixedMode = new FixedMode();
fixedMode.gasPriceTolerance = 1;
fixedMode.additionalComputationFactor = 0;
pricingMode.fixed = fixedMode;
const paymentLimitedMode = new PaymentLimitedMode();
paymentLimitedMode.gasPriceTolerance = 1;
paymentLimitedMode.paymentAmount = paymentAmount;
paymentLimitedMode.standardPayment = true;
pricingMode.paymentLimited = paymentLimitedMode;

const args = Args.fromMap({
target: CLValue.newCLPublicKey(
Expand Down
39 changes: 20 additions & 19 deletions migration-guide-v2-v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ const publicKey = privateKey.publicKey;

```typescript
const args = Args.fromMap({
target: CLValue.newCLPublicKey(
PublicKey.fromHex('<Recipient Public Key>')
),
amount: CLValueUInt512.newCLUInt512('2000000000') // 2 CSPR
target: CLValue.newCLPublicKey(
PublicKey.fromHex('<Recipient Public Key>')
),
amount: CLValueUInt512.newCLUInt512('2000000000') // 2 CSPR
});
```

Expand All @@ -216,7 +216,7 @@ const transactionTarget = new TransactionTarget({}); // Native target;

```typescript
const entryPoint = new TransactionEntryPoint(
TransactionEntryPointEnum.Transfer
TransactionEntryPointEnum.Transfer
);
```

Expand All @@ -230,30 +230,31 @@ const scheduling = new TransactionScheduling({}); // Standard;

```typescript
const pricingMode = new PricingMode();
const fixedMode = new FixedMode();
fixedMode.gasPriceTolerance = 2;
fixedMode.additionalComputationFactor = 0;
const paymentLimitedMode = new PaymentLimitedMode();
paymentLimitedMode.gasPriceTolerance = 1;
paymentLimitedMode.paymentAmount = paymentAmount;
paymentLimitedMode.standardPayment = true;

pricingMode.fixed = fixedMode;
pricingMode.paymentLimited = paymentLimitedMode;
```

5. **Create and Sign Transaction**:

```typescript
const transactionPayload = TransactionV1Payload.build({
initiatorAddr: new InitiatorAddr(publicKey),
ttl: new Duration(1800000),
args,
timestamp: new Timestamp(new Date()),
entryPoint,
scheduling,
transactionTarget,
chainName: 'casper-net-1',
pricingMode
initiatorAddr: new InitiatorAddr(publicKey),
ttl: new Duration(1800000),
args,
timestamp: new Timestamp(new Date()),
entryPoint,
scheduling,
transactionTarget,
chainName: 'casper-net-1',
pricingMode
});

const transaction = TransactionV1.makeTransactionV1(
transactionPayload
transactionPayload
);
await transaction.sign(privateKey);
```
Expand Down

0 comments on commit e95d8a2

Please sign in to comment.