Transactions
Submit Daml commands to Canton through PartyLayer's SDK.
Concepts
Canton transactions use Daml smart contracts. Each transaction is either:
- Create — Instantiate a new contract from a template
- Exercise — Execute a choice on an existing contract
Template IDs
Every Daml template is identified by three parts:
const templateId = {
package_id: 'cayvox-partylayer-1.0.0',
module_name: 'Cayvox.PartyLayer.RewardDelegation',
entity_name: 'RewardDelegation',
};Submitting a Create Command
import { useWallet } from '@partylayer/enterprise-react';
function CreateReward() {
const { submitTransaction } = useWallet();
const handleCreate = async () => {
const result = await submitTransaction({
templateId: {
package_id: 'cayvox-partylayer-1.0.0',
module_name: 'Cayvox.PartyLayer.RewardDelegation',
entity_name: 'RewardDelegation',
},
args: {
delegator: 'party_id_here',
operator: 'operator_party_id',
rewardRate: '0.05',
startDate: '2026-03-01',
totalClaimed: '0.0',
isActive: true,
},
});
console.log('Created:', result.commandId);
};
return <button onClick={handleCreate}>Create Delegation</button>;
}Exercising a Choice
const result = await submitTransaction({
templateId: {
package_id: 'cayvox-partylayer-1.0.0',
module_name: 'Cayvox.PartyLayer.RewardDelegation',
entity_name: 'RewardDelegation',
},
contractId: '00abcd1234::1220...',
choice: 'ClaimReward',
choiceArgs: {
amount: '100.0',
note: 'Monthly reward claim',
},
});Using the TransactionButton Component
import { TransactionButton } from '@partylayer/enterprise-react';
<TransactionButton
templateId={templateId}
choice="ClaimReward"
args={{ amount: '50.0', note: 'Claim' }}
contractId={contractId}
onSuccess={(result) => console.log('Success:', result)}
onError={(error) => console.error('Failed:', error)}
>
Claim Reward
</TransactionButton>Querying Contracts
import { useContracts } from '@partylayer/enterprise-react';
function ContractList() {
const { contracts, isLoading } = useContracts(
'Cayvox.PartyLayer.RewardDelegation'
);
if (isLoading) return <p>Loading...</p>;
return (
<ul>
{contracts.map((c) => (
<li key={c.contractId}>
Rate: {c.payload.rewardRate} — Active: {c.payload.isActive ? 'Yes' : 'No'}
</li>
))}
</ul>
);
}DamlValue Types
Daml uses a typed value system. The SDK handles serialization:
| Daml Type | TypeScript | Example |
|---|---|---|
| Party | string | 'alice::1220...' |
| Text | string | 'hello' |
| Int64 | string | '42' |
| Numeric | string | '3.14' |
| Bool | boolean | true |
| Date | string | '2026-03-01' |
| Optional | value or null | null |
| List | array | ['a', 'b'] |
Transaction Events
pl.on('tx:submitted', (tx) => {
console.log('Transaction submitted:', tx.commandId);
});
pl.on('tx:confirmed', (tx) => {
console.log('Transaction confirmed:', tx.updateId);
});
pl.on('tx:failed', (error) => {
console.error('Transaction failed:', error);
});