VIA Protocol allows developers to build applications that seamlessly operate across multiple blockchains and access private off chain data providing a unified experience for users regardless of their network from web2 to web3, large or small, public or private.
// Cross-Chain Native Tokens
Move custom tokens between chains without wrapping or bridges. One contract, multiple chains, native representation.
// Bridge tokens to another chain
function bridge(uint _destChainId, address _recipient, uint _amount) external {
_burn(msg.sender, _amount);
_sendMessage(_destChainId, abi.encode(_recipient, _amount));
emit TokensBridged(msg.sender, _destChainId, _recipient, _amount);
}
// Process incoming tokens from another chain
function _processMessage(uint _sourceChainId, uint, bytes calldata _data) internal override {
(address _recipient, uint _amount) = abi.decode(_data, (address, uint));
_mint(_recipient, _amount);
emit TokensReceived(_sourceChainId, _recipient, _amount);
}
// Cross-Chain NFTs
Seamless NFT transfers with metadata between networks. Preserve provenance and history across blockchain ecosystems.
// Bridge NFT to another chain
function bridge(uint _destChainId, address _recipient, uint _nftId) external {
// Store metadata before burning
NFTMetadata memory metadata = _tokenMetadata[_nftId];
_burn(_nftId);
_sendMessage(_destChainId, abi.encode(_recipient, _nftId, metadata));
emit NFTBridged(msg.sender, _nftId, _destChainId, _recipient);
}
// Process incoming NFT from another chain
function _processMessage(uint _sourceChainId, uint, bytes calldata _data) internal override {
(address _recipient, uint _nftId, NFTMetadata memory metadata) =
abi.decode(_data, (address, uint, NFTMetadata));
// Mint the NFT on this chain with original metadata
_mint(_recipient, _nftId);
_tokenMetadata[_nftId] = metadata;
emit NFTReceived(_recipient, _nftId, _sourceChainId);
}
// Private Oracles
Connect contracts to off-chain private data sources and APIs with secure oracles. Bring real-world data on-chain without compromising security.
// Request data from private oracle
function requestWeather(string memory _zipcode) external returns (uint) {
uint requestId = nextRequestId++;
bytes memory featureData = abi.encode(requestId, _zipcode);
_sendMessageWithFeature(
block.chainid,
"",
1, // Feature ID for Private Oracle
featureData
);
emit WeatherRequested(requestId, msg.sender, _zipcode);
return requestId;
}
// Process incoming data from oracle
function _processMessageWithFeature(
uint, uint, bytes memory, uint32, bytes memory, bytes memory _featureResponse
) internal override {
// Decode the feature response
(uint requestId, string memory temperature, string memory conditions, string memory location) =
abi.decode(_featureResponse, (uint, string, string, string));
// Store the weather data
weatherRequests[requestId].temperature = temperature;
weatherRequests[requestId].conditions = conditions;
weatherRequests[requestId].location = location;
weatherRequests[requestId].timestamp = block.timestamp;
weatherRequests[requestId].fulfilled = true;
emit WeatherReceived(requestId, temperature, conditions, location);
}
VIA Protocol's architecture is built on three core components:
The MessageClient
is a Solidity contract that provides a simple interface for cross-chain communication. It abstracts away the complexity of cross-chain messaging, allowing developers to focus on their application logic.
// Send a message to another chain
_sendMessage(destChainId, abi.encode(data));
// Process incoming messages
function _processMessage(uint _sourceChainId, uint, bytes calldata _data) internal virtual override {
// Decode and process the message
(address recipient, uint amount) = abi.decode(_data, (address, uint));
// Your logic here
}
Our protocol is secured by a decentralized network of validators that ensure transaction integrity and provide multi-layer consensus. This network:
- Validates cross-chain messages
- Ensures message delivery
- Prevents double-spending
- Maintains network security
Private Oracles allows for extensible functionality beyond basic messaging:
- Private Datasources: Connect smart contracts to off-chain databases or APIs
- Custom Logic: Implement complex cross-chain business logic
- Real World Reach: Communicate with real world devices through IoT APIs or embedded systems integrations
Jump right in with our quickstart repositories:
Create and deploy a cross-chain native ERC20 token in minutes. git clone https://github.com/VIALabs-io/quickstart-token.git
cd quickstart-token
npm install
node scripts/deploy.js |
Build a cross-chain native NFT collection with metadata preservation. git clone https://github.com/VIALabs-io/quickstart-nft.git
cd quickstart-nft
npm install
node scripts/deploy.js |
Connect your contracts to off-chain data sources. git clone https://github.com/VIALabs-io/quickstart-oracle.git
cd quickstart-oracle
npm install
node scripts/deploy.js |
Contact us at [email protected] for collaborations and partnerships