Package Exports
- @dbtchain/gov-sdk
- @dbtchain/gov-sdk/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dbtchain/gov-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@dbtchain/gov-sdk
Public SDK for simplified blockchain interactions with the Digital Bayanihan Transparency Chain (DBTC).
Installation
npm install @dbtchain/gov-sdkQuick Start
Option 1: Using Environment Variables (Recommended)
Set these environment variables:
DBTC_CHAIN_MODE=testnet # or 'mainnet'
DBTC_API_KEY=your-api-key # Provided by DBTC
PRIVATE_KEY=your-wallet-private-keyThen use the SDK:
import { getCurrentPhase, getPhaseName, submitProposal } from '@dbtchain/gov-sdk';
// SDK auto-configures from environment variables
const phase = await getCurrentPhase();
console.log('Current Phase:', getPhaseName(phase));Option 2: Programmatic Configuration
import { configure, submitProposal } from '@dbtchain/gov-sdk';
configure({
chainMode: 'testnet', // 'testnet' (Polygon Amoy) or 'mainnet' (Polygon)
apiKey: 'your-dbtc-api-key',
privateKey: process.env.PRIVATE_KEY
});Networks
| Mode | Network | Chain ID | RPC Endpoint |
|---|---|---|---|
testnet |
Polygon Amoy | 80002 | https://amoy.dbtc.bayanichain.io |
mainnet |
Polygon | 137 | https://polygon.dbtc.bayanichain.io |
Usage Examples
Agency Actions
import {
submitProposal,
reviseProposal,
addDocumentManager,
getAgencyInfo
} from '@dbtchain/gov-sdk';
// Submit a budget proposal
const result = await submitProposal(
'0xAgencyAddress',
'ipfs://metadata-uri',
{
prexcFpapId: 'PREXC-001',
uacsObjCode: 'PS-001',
amount: 1000000n
}
// privateKey optional if set in env/config
);
console.log('Token ID:', result.tokenId);
// Revise a proposal
const revision = await reviseProposal(
'0xAgencyAddress',
result.tokenId,
'ipfs://new-metadata-uri',
{ prexcFpapId: 'PREXC-001', uacsObjCode: 'PS-001', amount: 1100000n },
'Updated amount based on new requirements'
);
// Add document manager (requires agency owner key)
await addDocumentManager(
'0xAgencyAddress',
'0xManagerAddress',
process.env.AGENCY_OWNER_KEY // explicit key if different from default
);
// Get agency info (read-only, no key needed)
const info = await getAgencyInfo('0xAgencyAddress');
console.log(info);Department Actions
import { addAgency, getDepartmentInfo } from '@dbtchain/gov-sdk';
// Add a new agency
const result = await addAgency(
'0xDepartmentAddress',
'002',
'Bureau of Treasury',
'0xAgencyOwnerAddress'
);
console.log('New Agency:', result.agencyAddress);
// Get department info
const info = await getDepartmentInfo('0xDepartmentAddress');
console.log(info);DBTC Phase Management (DBM Only)
import {
addDepartment,
assignPhaseResponsibility,
startBudgetCall,
advancePhase,
BudgetPhase
} from '@dbtchain/gov-sdk';
// Add a department
const result = await addDepartment(
'02',
'Department of Finance',
'Office of the Secretary',
'0xOwnerAddress',
false, // not standalone
true // actual department
);
// Assign phase responsibility
await assignPhaseResponsibility(BudgetPhase.BUDGET_CALL, '02');
// Start budget call
await startBudgetCall();
// Advance phase
await advancePhase();API Reference
Configuration
configure(config)- Configure the SDKgetChainMode()- Get current chain modeisTestnet()/isMainnet()- Check current network
Agency Functions
submitProposal()- Submit a budget proposalreviseProposal()- Revise an existing proposalamendProposal()- Amend a proposal during GAB phasesubmitSeparateGAB()- Submit separate House/Senate GABsubmitJointGAB()- Submit joint bicameral GABaddDocumentManager()- Add a document managerremoveDocumentManager()- Remove a document managertransferAgencyOwnership()- Transfer agency ownershipgetAgencyInfo()- Get agency informationisDocumentManager()- Check if address is document managergetDocumentManagers()- Get all document managers
Department Functions
addAgency()- Add a new agencysetHouseAndSenate()- Set Congress House/Senate agenciesgetDepartmentInfo()- Get department informationgetAgency()- Get agency by codeisAgencyRegistered()- Check if agency is registeredgetAgencyCodes()- Get all agency codesgetMainAgency()- Get main agency addressgetHouseAgency()/getSenateAgency()- Get Congress agenciesgetDepartmentOwner()- Get department owner
DBTC Functions
addDepartment()- Add a new departmentaddRegularDepartment()- Add a regular departmentassignPhaseResponsibility()- Assign phase responsibilitystartBudgetCall()- Start budget call phaseadvancePhase()- Advance to next phasegetCurrentPhase()- Get current budget phasegetCurrentFiscalYear()- Get current fiscal yeargetDepartment()- Get department by codeisDepartmentRegistered()- Check if department is registeredgetDepartmentCodes()- Get all department codesgetDepartmentCount()- Get department countgetPhaseResponsibleDepartment()- Get responsible department for phasegetBudgetProposalContract()- Get BudgetProposal contract addressgetDBTCOwner()- Get DBTC owner
Getting Your API Key
Contact DBTC to obtain your API key for accessing the blockchain network.
License
MIT