Social App ​
A decentralized social media mini app demonstrating on-chain posts, global feeds, and real-time updates using Move contracts and view functions.
Overview ​
The Social App demonstrates:
- On-chain post storage using Move contracts
- Global feed aggregation
- View functions for reading blockchain data
- Transaction-based post creation
- Reaction system with on-chain state
- Real-time feed updates
Repository ​
The Social app is available in the mini-app-social directory of the mini-app-examples repository.
Quick Start ​
Prerequisites ​
- Node.js 18+ and npm/pnpm
- Movement Everything (ME) app installed on your mobile device
- Deployed Move contract (or use the testnet deployment)
Setup ​
- Install dependencies:
cd mini-app-social
npm install
# or
pnpm install- Configure contract address:
Update constants.ts with your deployed contract address:
export const SOCIAL_MODULE_ADDRESS = '0x...';Or use the testnet deployment:
0xe08098cd9db04d38b7962a4e2653c2b7362477943c47e976ed55c624b759580f- Run the development server:
npm run dev
# or
pnpm dev- Open in ME app:
Open the Movement Everything (ME) app on your mobile device and navigate to this mini app.
Features ​
On-Chain Posts ​
- Create posts - Store messages permanently on the blockchain
- User feeds - Each user has their own feed of posts
- Global feed - Aggregated feed of all posts across all users
- Reactions - React to posts with on-chain state
View Functions ​
The app uses sdk.view() to read on-chain data without requiring wallet connection:
get_global_count()- Total number of posts in global feedget_global_pointer(index)- Get pointer to a post in global feedget_post(owner, index)- Get a specific post by owner and indexget_post_count(owner)- Get number of posts for a user
Transaction Functions ​
post(content)- Create a new on-chain postreact(owner, index)- React to a specific post
Architecture ​
Move Contract ​
The social.move contract provides:
- Feed struct - Stores posts for each user
- GlobalIndex - Aggregates pointers to all posts
- Post struct - Contains author, content, timestamp, reactions
Frontend Flow ​
- Load feed - Use
sdk.view()to fetch global feed count - Fetch posts - Iterate through global pointers and fetch each post
- Create post - Use
sdk.sendTransaction()to callpost()function - React - Use
sdk.sendTransaction()to callreact()function
Key Files ​
app/page.tsx- Main social feed UI and logicconstants.ts- Contract address configurationmove/sources/social.move- On-chain social contract
Contract Address ​
The social contract is deployed on testnet at:
0xe08098cd9db04d38b7962a4e2653c2b7362477943c47e976ed55c624b759580fSDK Features Used ​
view()- Read posts and feed data from contractsendTransaction()- Create posts and reactionsgetUserInfo()- Get connected wallet addressisInstalled()- Check if running in ME appready()- Wait for SDK initialization
Use Cases ​
- Social apps - Learn how to build decentralized social networks
- On-chain data - See how to store and retrieve data on blockchain
- View functions - Understand read-only blockchain queries
- Feed aggregation - Learn patterns for aggregating on-chain data
- Real-time updates - See how to refresh data without transactions
Code Examples ​
Reading Posts with View Functions ​
// Get global feed count
const count = await sdk.view({
function: `${SOCIAL_MODULE_ADDRESS}::social::get_global_count`,
functionArguments: []
});
// Get a specific post
const post = await sdk.view({
function: `${SOCIAL_MODULE_ADDRESS}::social::get_post`,
functionArguments: [ownerAddress, postIndex]
});Creating a Post ​
const result = await sdk.sendTransaction({
function: `${SOCIAL_MODULE_ADDRESS}::social::post`,
functionArguments: [message]
});Reacting to a Post ​
const result = await sdk.sendTransaction({
function: `${SOCIAL_MODULE_ADDRESS}::social::react`,
functionArguments: [postOwner, postIndex]
});Troubleshooting ​
"SDK not available" - Make sure you're running inside the ME app
"View function failed" - Check that the contract address is correct and the contract is deployed
"Posts not loading" - Verify the contract address in constants.ts matches your deployment
"Transaction failed" - Ensure your wallet is connected and has testnet MOVE tokens
Next Steps ​
- Explore the SDK API Reference for detailed method documentation
- Learn about View Functions for reading on-chain data
- Check out the Scaffold App for more SDK examples
- Read about Send Transaction for on-chain operations
